Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)

  • drrxa
    Participant

    @drrxa

    Forgot to mention that I am running BP 1.6.4 on WP 3.5.1

    Thx


    drrxa
    Participant

    @drrxa

    Thanks r-a-y, I understand now.


    drrxa
    Participant

    @drrxa

    Thanks for reply Paul. And yes, WP won’t check for that and if called twice there will be double headers and footers.

    What I have found that these settings files (located in `bp-themes/bp-default/members/single/settings/`) are not loaded by the file `members/single/settings.php` and that is maybe why they override the original layout (they have for example their own `get_header, get_footer`, and `get_sidebar`). I found that by commenting the block of code responsible for loading these files in `settings.php` file which is:
    `
    <?php
    /*
    if ( bp_is_current_action( ‘notifications’ ) ) :
    locate_template( array( ‘members/single/settings/notifications.php’ ), true );

    elseif ( bp_is_current_action( ‘delete-account’ ) ) :
    locate_template( array( ‘members/single/settings/delete-account.php’ ), true );

    elseif ( bp_is_current_action( ‘general’ ) ) :
    locate_template( array( ‘members/single/settings/general.php’ ), true );

    else :
    locate_template( array( ‘members/single/plugins.php’ ), true );

    endif;
    */
    ?>
    `

    And the file still loading correctly, while doing the same thing in `members/single/profile.php` will break the theme loading.

    I dont have specific need for that, but I am just curious about where these files are loaded from and why they dont follow the same procedure? I have made a custom header for logged-in users `get_heade(‘loggedin’)` and rather than only modifying the `home.php` file header only, I had to modify the header of these four settings files as well `capabilities.php, delete-account.php, general.php, notifications.php`.


    drrxa
    Participant

    @drrxa

    I have the same question. Does WP checks if a template file loading already has a `get_header` and `get_footer`? and if so will ignore the header and footer loaded from the parent file? it is really confusing.


    drrxa
    Participant

    @drrxa

    I have a working code now, the following code is able to insert a select box profile field to the ‘base’ group with any long list of options that might be hard to insert manually through the user interface. this specific example will insert a profile field with the title of “Country” that contains all countries as options. Use this code in your `functions.php` or `bp-custom.php` file and you will notice a new profile field with the title of “Country” the next time you visit the Base group in Profile Fields admin area. You can then update and change the options to suit your needs and after that click “Save” button to register this field.

    Be aware that the following code will not add a new “Country” profile field as long as a profile field with the title of “Country” already exists, meaning that if you change the title to “List of Countries” for example, it will add a new profile field with the title of “Country” to your profile field, so I think it is better to use this code only once and whenever you need to insert a long listed profile field, and then remove the code from `functions.php` or `bp-custom.php` and keep on other place for future use.
    `
    add_action(‘bp_init’, ‘add_custom_country_list’); // That might not be the perfect hook to use
    function add_custom_country_list() {
    if (xprofile_get_field_id_from_name(‘Country’)) return;
    $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);
    if ($country_list_id) {
    $countries = array(‘USA’,’Germany’,’England’); // Google for “country list php” and replace this one
    foreach ($countries as $i => $country) {
    xprofile_insert_field(array(
    ‘field_group_id’ => 1,
    ‘parent_id’ => $country_list_id,
    ‘type’ => ‘selectbox’, // it is ‘selectbox’ not ‘option’
    ‘name’ => $country,
    ‘option_order’ => $i+1
    ));
    }
    }
    }
    `


    drrxa
    Participant

    @drrxa

    My specific problem is that I need to add a country select box to the extended user profile that will appear in registration form and I don’t want to add it through the admin panel because (1) it is hard to enter 256 countries manually and (2) I will need multiple instances of that list.

    Now I came up with the following code after a while of digging into the core files of BuddyPress, the first part that add the ‘Country’ `selectbox` works fine, but the second part which is supposed to add the countries options does not wok, I get an empty `selectbox` that is labeled “Country” without any options:

    `
    add_action(‘bp_init’, ‘add_custom_country_list’); // That might not be the perfect hook to use
    function add_custom_country_list() {
    if (xprofile_get_field_id_from_name(‘Country’)) return;
    $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); // It work till here – The following part does not work
    if ($country_list_id) {
    $country_list = array(‘USA’,’Germany’,’England’); // To be replaced with the full country list
    foreach ($country_list as $i => $country) {
    xprofile_insert_field(array(
    ‘field_group_id’ => 1,
    ‘parent_id’ => $country_list_id,
    ‘type’ => ‘option’,
    ‘name’ => $country,
    ‘option_order’ => $i+1
    ));
    }
    }
    }
    `
    Can anyone help me about what is wrong with this code? Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
Skip to toolbar