This topic has 7 replies, 2 voices, and was last updated 11 years by JohnDoe.

  • Author
  • #5645
     JohnDoe
    Participant

    i was wondering if this would work, to paste the following code in bp-custom.php


    function bp_add_custom_city_list() {

    if ( !xprofile_get_field_id_from_name('City') && 'bp-profile-setup' == $_GET['page'] ) {

    $city_list_args = array(
    'field_group_id' => 1,
    'name' => 'City',
    'description' => 'Please select your city',
    'can_delete' => false,
    'field_order' => 1,
    'is_required' => false,
    'type' => 'selectbox',
    'order_by' => 'default'

    );

    $city_list_id = xprofile_insert_field( $city_list_args );

    if ( $city_list_id ) {

    $cities = array(
    "city",
    "city",

    foreach ( $cities as $i => $city ) {
    xprofile_insert_field( array(
    'field_group_id' => 1,
    'parent_id' => $city_list_id,
    'type' => 'selectbox',
    'name' => $city,
    'option_order' => $i+1
    ));
    }
    }
    }

    }
    add_action('bp_init', 'bp_add_custom_city_list');

    #5648
     JohnDoe
    Participant

    I meant in bp-functions.php

    #5650
     JohnDoe
    Participant

    Updated Code to :


    //Custom City list
    function bp_add_custom_city_list() {

    if ( !xprofile_get_field_id_from_name($bp_fields['city']) && 'bp-profile-setup' == $_GET['page'] ) {

    $city_list_args = array(
    'field_group_id' => 1,
    'name' => $bp_fields['city'],
    'description' => 'Please select your city',
    'can_delete' => false,
    'field_order' => 6,
    'is_required' => true,
    'type' => 'selectbox',
    'order_by' => 'default'

    );

    $city_list_id = xprofile_insert_field( $city_list_args );

    if ( $city_list_id ) {

    $cities = array(
    "city",
    "city",
    );

    foreach ( $cities as $i => $city ) {
    xprofile_insert_field( array(
    'field_group_id' => 1,
    'parent_id' => $city_list_id,
    'type' => 'selectbox',
    'name' => $city,
    'option_order' => $i+1
    ));
    }
    }
    }

    }
    add_action('bp_init', 'bp_add_custom_city_list');

    #5651
     JohnDoe
    Participant

    @adam what do you think about this?

    #5682
     SQadmin
    Keymaster

    See how we did it for the countries in wp-content/themes/sweetdate/custom_buddypress/bp-functions.php lines: 290 – 518

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5688
     JohnDoe
    Participant
    This reply has been set as private.
    #5748
     SQadmin
    Keymaster

    We will have something like that in next update.. so maybe is best to wait for it 😉
    it will be released this month

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #5751
     JohnDoe
    Participant

    very great 😀 Robert, it keeps getting better and better. ^^

Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?