This topic has 2 replies, 2 voices, and was last updated 9 years by wbz.

  • Author
  • #78856
     wbz
    Participant

    Hello,

    I got a code to add a country list to the user xprofile field section. Code snippet below. I pasted in a newly created bp-custom.php file in /wp-content/plugins/buddypress directory but the country field is not displayed in the Users/Profile Fields section in the dashboard.

    I also pasted the bp-custom file in the /wp-content/plugins/ directory but same result.

    Kindly assist.

    COPY CODE
    function bp_add_custom_country_list() {
     
      if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
     
    		$country_list_args = array(
    		       'field_group_id'  => 1,
    		       'name'            => 'Country',
    		       'description'	 => 'Please select your country',
    		       'can_delete'      => true,
    		       'field_order' 	 => 2,
    		       'is_required'     => false,
    		       'type'            => 'selectbox',
    		       'order_by'	 => 'custom'
     
    		);
     
    		$country_list_id = xprofile_insert_field( $country_list_args );
     
    		if ( $country_list_id ) {
     
    			$countries = array(
    				"United States",
    				"Zambia",
    				"Zimbabwe"
    			);
    			
    			foreach (  $countries as $country ) {
    				
    				xprofile_insert_field( array(
    					'field_group_id'	=> 1,
    					'parent_id'		=> $country_list_id,
    					'type'			=> 'option',
    					'name'			=> $country,
    					'option_order'   	=> $i++
    				));
    				
    			}
     
    		}
    	}
    }
    add_action('bp_init', 'bp_add_custom_country_list');
    #78948
     sharmstr
    Moderator

    That’s not a function of the theme. If you are using a child theme, you can try it in your functions.php file. If not, you should temporarily enable the default WP 2015 Theme to see if your custom code works or not.

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

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #78990
     wbz
    Participant

    Thanks, it shows up in the front end user profile but not at the back end. i guess i’ll make do with that till i get it to work out.

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

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?