-
Author
Tagged: bp-custom.php, XProfile fields
-
September 22, 2015 at 05:49 #78856wbzParticipant
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 CODEfunction 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');
September 22, 2015 at 18:36 #78948sharmstrModeratorThat’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 solutionThis support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com
-
AuthorPosts
The forum ‘General questions’ is closed to new topics and replies.