Search blog

Friday, September 15, 2017

Add Country Selection List to your BuddyPress Profile & Registration Page

Add Country List in BuddyPress Profile & Registration Page

In this tutorial I will show you how you can easily add a Country list, as shown in the image above to your BuddyPress User Extended Profiles or Wordpress Registration Page using BuddyPress.

1. First head over to Github & download the following code:

As you must have noticed in the comments, in the Github page of the above code; you may have to add the following line of code just before the foreach loop at line number 222; which is basically, you are initializing the value of $i to 1. 

 $i = 1;  //

Copy the above code and add it to your 'bp-custom.php' file. If this file already exists in your site then it should be located at 'wp-contents/plugins/bp-custom.php'; else you have to create it and place it at the aforementioned location. You can read more about 'bp-custom.php' file here: There you will be able to understand why it's best to add the above code in your 'bp-custom.php' file and not in your theme's 'function.php' file.

Now, open the following link to access the Country List. Suppose, your site name is, then you will have to enter: You should now be able to view a Country List field as shown in the image below:

 - Once you are able to view the Country List in your Profile Fields page you may remove the above code from your 'bp-custom.php' file, else your 'bp_xprofile_fields' table, which is the table that stores the above country list might go on getting unnecessarily populated with the all the above 193 country names.
- Only edit your field after removing the above code from your bp-custom.php file for aforementioned reasons.
- If you would like to have the Delete option for this field in your Profile Fields Admin Page, then  change line 14 as below:
 'can_delete'   => true,  

- Likewise you can also alter the value of the 'name' and 'description' fields in the code itself.


  1. Worked like a charm!
    Thanks a million.

  2. I don't seem to be able to get it to work. Once I amended the set-up link with my domain it just goes to the wordpress login page. Once I login, I am just taken to the WP Dashboard. When I go to the profile field there is no change.

  3. Hi there

    Please ignore my earlier message, I got it to work by removing the snippet you suggested.

    Thank you so much.


Thank you for your Feedback!

Top 5 Posts (Weekly)