Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)

  • webheadcoder
    Participant

    @webheadllc

    This code worked except my options weren’t ordered correctly. The option_order arg didn’t work. It looks like option_order does not get saved in the database. Instead I used the following code where it uses whatever order the country array is in:

    `function your_plugin_activation() {
    //country
    wh_add_country_list();
    }
    //on activation or if you add this to functions use add_action ‘bp_init’
    register_activation_hook(__FILE__, ‘your_plugin_activation’);

    function wh_add_country_list() {
    if (xprofile_get_field_id_from_name(‘Country’)) return;

    add_filter(‘xprofile_field_options_before_save’, ‘wh_countries’);
    add_filter(‘xprofile_field_default_before_save’, ‘wh_country_option_default’);
    $country_list_args = array(
    ‘field_group_id’ => 1,
    ‘type’ => ‘selectbox’,
    ‘name’ => ‘Country’,
    ‘description’ => ‘Please select your country’,
    ‘is_required’ => true,
    ‘can_delete’ => false,
    ‘order_by’ => ‘default’
    );
    $country_list_id = xprofile_insert_field($country_list_args);
    remove_filter(‘xprofile_field_options_before_save’, ‘wh_countries’);
    remove_filter(‘xprofile_field_default_before_save’, ‘wh_country_option_default’);
    }

    function wh_country_option_default() {
    return array(‘US’ => 1);
    }

    function wh_countries() {
    return array(
    ‘US’ => ‘United States’
    //list of other countries
    );
    }`

Viewing 1 replies (of 1 total)
Skip to toolbar