Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Installation & Updates › Required Plugins Installation and Updates › Profile registration data
- This topic has 3 replies, 2 voices, and was last updated 6 years, 9 months ago by
Themosaurus.
-
AuthorPosts
-
SiX InformaticsParticipant@xailaes
- 22 Topics
- 66 Posts
One question, I downloaded the demo data and all the countries are in the profile data.
We will work only in one country, but we have different populations. Do you have any automatic way to put all the populations/cities?
Thanks
August 1, 2018 at 14:16 #1511@themosaurus- 1 Topics
- 1675 Posts
Hi SiX Informatics,
There is no real automatic way of putting all cities in a field. However you can add a large number of options more easily by creating the field with PHP code.
As an example, here is a code snippet to add a “Location” field in BuddyPress profiles:
$field_name = 'Location'; if ( function_exists( 'xprofile_get_field_id_from_name' ) && ! xprofile_get_field_id_from_name( $field_name ) ) { $field_id = xprofile_insert_field( array( 'field_group_id' => 1, 'name' => $field_name, 'field_order' => 200, 'is_required' => true, 'type' => 'selectbox', 'can_delete' => 1, ) ); if ( $field_id ) { $options = array( 'New York City', 'Los Angeles', 'Chicago', 'Houston', 'Philadelphia', ); foreach ( $options as $i => $option ) { xprofile_insert_field( array( 'field_group_id' => 1, 'parent_id' => $field_id, 'type' => 'selectbox', 'name' => $option, 'option_order' => $i + 1, ) ); } } }
With this example, you only need to change
'Location'
with the name of the field you want to add. Then you can easily change the list of$options
with your own list of cities.If you want to add this code snippet to your website, we advise that you use the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). You can also refer to this article of our documentation for more information about Code Snippets:
We hope this can help you with your setup.
Best regards,
August 2, 2018 at 09:50 #1525SiX InformaticsParticipant@xailaes- 22 Topics
- 66 Posts
perfect
Thank you very much
August 2, 2018 at 13:43 #1532@themosaurus- 1 Topics
- 1675 Posts
You’re welcome 🙂
Best regards,
August 2, 2018 at 15:24 #1533 -
AuthorPosts
The topic ‘Profile registration data’ is closed to new replies.