Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Website Setup › Pages › Display City on User Profile
- This topic has 13 replies, 5 voices, and was last updated 6 years, 1 month ago by
Themosaurus.
-
AuthorPosts
-
princeParticipant@prince22
- 12 Topics
- 19 Posts
Hi there,
First all of this is an outstanding theme. Great work!
On the demo you have the city showing for the user profile under “meet our active members” or when you search for members.
How can I display city for the user profile?
On my site it currently displays name for the user profile but it doesn’t show any other information.
Thanks for your help!
August 29, 2018 at 12:20 #1876@themosaurus- 1 Topics
- 1675 Posts
Hi prince,
Thank you for the kind words! ?
From what we’ve understood, it seems that you have skipped some steps from the setup guide. It’s best to complete every step before going to next otherwise some imports will be broken, like your homepage and directory search forms, for instance.
First, you need to go to your BuddyPress settings and finish its setup:
This step will help you to generate all the missing profile fields, like City.
Your next step will be re-save your homepage and directory search forms.
We use BP Profile Search (https://wordpress.org/plugins/bp-profile-search/) to showcase the profile search feature on our demos.
You can edit the homepage search form by visiting “Users > Profile Search” in your dashboard, where you will find every existing profile search forms.
Just edit your forms and click “Save” without changing anything.Finally, to learn more about profile search forms, please read also the following posts:
This should solve your issue.
Best regards,
August 29, 2018 at 15:06 #1882princeParticipant@prince22- 12 Topics
- 19 Posts
Hi there,
I’m back working on this but I wasn’t able to display city on the members directory page. It currently shows the name of the user under the profile picture. On the demo there’s city and age. I’m only interested in having the name and city for the user profile on members directory page.
I have followed the steps below as you mentioned above:
– Installation of Buddypress set-up complete but I did not do the default fields generation. I added my own fields including city. Under profile fields have Name, About, City, etc. I also re-ordered these to show city under the member directory but didn’t work.
– I added BP Profile Search and it works.Currently the members directory page shows the user profile picture and the name below. But I would like to display city below the name like you have shown on the demo here but no age: https://youth.gwangi-theme.com/members-directory-sidebar-right/
Can you please help with this?
Thanks for your help!
September 19, 2018 at 16:41 #2362@themosaurus- 1 Topics
- 1675 Posts
Hi @prince22,
The “city”, “country” and “age” field displayed on this demo (https://youth.gwangi-theme.com/members-directory-sidebar-right/) are only available if you use our generated fields.
As described here (https://doc.themosaurus.com/finishing-buddypress-setup/) you can generate the default fields. Only these are the ones that are displayed on member lists and member profile.
But you can also display a BP xProfile of your choice by adding the following code snippet to your website:
if ( ! function_exists( 'gwangi_buddypress_member_country' ) ) : /** * Print the HTML for the BP xProfile country field. * * @since 1.0.0 */ function gwangi_buddypress_member_country() { if ( function_exists( 'xprofile_get_field_data' ) ) : $country = xprofile_get_field_data( 'Country', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); if ( ! empty( $country ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-country"><?php echo wp_kses( $country, $allowed_html ); ?></div> <?php endif; endif; } endif;
Note that your field must have this exact name : “Country”.
To add this code snippet to your site, we recommend that you use a the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/). If you have never activated this plugin, please read the following post:
We hope this will solve your issue. ?
September 20, 2018 at 16:29 #2416princeParticipant@prince22- 12 Topics
- 19 Posts
Oh I see! So would it possible to only have the Name and City for each user profile under members directly page with the above code? Or if I generate the default field and modify them?
Thanks so much again for the clarification.
September 20, 2018 at 17:20 #2420@themosaurus- 1 Topics
- 1675 Posts
Hi @prince22,
Yes, you can simply generate the default fields and delete the ones you don’t need to (for example “City”).
This code is only necessary if you want to display a field that has not been generated by clicking on the button (for example a “hobby” field that you have created by yourself).
We hope this helps.
Regards,
September 20, 2018 at 17:29 #2422BENParticipant@benbusiness- 6 Topics
- 15 Posts
I created a xprofile field called location then in code snippet I inserted this code below but it didn't work if ( ! function_exists( 'gwangi_buddypress_member_country' ) ) : /** * Print the HTML for the BP xProfile country field. * * @since 1.0.0 */ function gwangi_buddypress_member_country() { if ( function_exists( 'xprofile_get_field_data' ) ) : $Location = xprofile_get_field_data( 'Location', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); if ( ! empty( $location ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-country"><?php echo wp_kses( $location, $allowed_html ); ?></div> <?php endif; endif; } endif; I want to display a modified field in xprofile field. thanks
November 22, 2018 at 17:40 #3728@themosaurus- 1 Topics
- 1675 Posts
Hi @benbusiness,
It seems that there’s a minor misspelling error that leads to the
$location
not receiving the value from your field as it’s written$Location
at the beginning of your code.
Alsogwangi_buddypress_member_country
is not displayed in your current version of Gwangi. It’s best if you usegwangi_buddypress_member_location
instead.Could please retest with the following snippet?
if ( ! function_exists( 'gwangi_buddypress_member_location' ) ) : /** * Print the HTML for the location XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_location() { if ( function_exists( 'xprofile_get_field_data' ) ) : $location = xprofile_get_field_data( 'Location', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); if ( ! empty( $location ) && ! empty( $country ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $location, $allowed_html ); ?></div> <?php endif; endif; } endif;
Thank you for keeping us updated.
November 23, 2018 at 17:49 #3752SumitParticipant@sumit784- 4 Topics
- 10 Posts
Hi,
I am building a matrimony match website and have created multiple custom profile fields. Out of this I have to show the following fields on header1) Age
2) Current Location
3) Education
4) Profile managed by
5) About MeHow can I show these fields on the profile header alongwith the existing 2 fields display.
I have the snippet plugin installed and setup, and tried this snippet but it didnt’ show anything.
if ( ! function_exists( ‘gwangi_buddypress_member_profileManagedBy’ ) ) :
/**
* Print the HTML for the BP xProfile profilemanagedby field.
*
* @since 1.0.0
*/
function gwangi_buddypress_member_profileManagedBy() {
if ( function_exists( ‘xprofile_get_field_data’ ) ) :
$profilemanagedby = xprofile_get_field_data( ‘Profile managed by’, bp_get_member_user_id() );
$allowed_html = array(
‘a’ => array(
‘href’ => array(),
‘rel’ => array(),
),
);
if (! empty( $profilemanagedby ) ) : ?>
<div class=”bp-member-xprofile-custom-field bp-member-location”><?php echo wp_kses( $profilemanagedby, $allowed_html ); ?></div>
<?php
endif;
endif;
}
endif;December 29, 2018 at 22:41 #4345@themosaurus- 1 Topics
- 1675 Posts
Hi @sumit784,
As mentioned above, you can also display each BP xProfile field of your choice by adding the following code snippet to your website:
if ( ! function_exists( 'gwangi_custom_buddypress_member_xprofile_custom_fields' ) ) : /** * Print the HTML for the custom XProfile fields in the BP Member Header. * * @since 1.0.0 */ function gwangi_custom_buddypress_member_xprofile_custom_fields() { if ( function_exists( 'xprofile_get_field_data' ) ) : $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); // TODO: Repeat for each field to display. $my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id() ); if ( ! empty( $my_field ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $my_field, $allowed_html ); ?></div> <?php endif; // TODO: End repeat. endif; } endif; add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_custom_buddypress_member_xprofile_custom_fields', 20 );
Simply replace the $my_field variable by yours (for instance, $age) and replace ‘My Field’ by ‘Age’. Don’t forget to repeat these lines for each field that you wish to display.
It should do the trick.
Please also be informed that our support forum will be closed during on December 31st, 2018 and January 1st, 2019.
Regards,
December 31, 2018 at 00:03 #4350@themosaurus- 1 Topics
- 1675 Posts
Hi @sumit784,
For multi checkbox fields, in the previous snippet you just need to change this line:
$my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id() );
Like this:
$my_field = xprofile_get_field_data( 'My Field', bp_get_member_user_id(), 'comma' );
Don’t forget to replace $my_field and ‘My Field’ by the field of your choice.
Regards,
January 3, 2019 at 14:58 #4363Malas RedaParticipant@malasreda- 13 Topics
- 28 Posts
Hello,
I am using this code snippet to show on the member directory some fields. Everything is working fine but the field “vos fantasmes” won’t diplay. It shows array instead. The field in question is a check box ! how can i make it work ?
if ( ! function_exists( 'gwangi_custom_buddypress_member_xprofile_custom_fields' ) ) : /** * Print the HTML for the custom XProfile fields in the BP Member Header. * * @since 1.0.0 */ function gwangi_custom_buddypress_member_xprofile_custom_fields() { if ( function_exists( 'xprofile_get_field_data' ) ) : $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); // TODO: Repeat for each field to display. $êtes_vous = xprofile_get_field_data( 'Êtes-vous', bp_get_member_user_id() ); if ( ! empty( $êtes_vous ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $êtes_vous, $allowed_html ); ?></div> <?php endif; $vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id() ); if ( ! empty( $vos_fantasmes ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-my_field"><?php echo wp_kses( $vos_fantasmes, $allowed_html ); ?></div> <?php endif; // TODO: End repeat. endif; } endif; add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_custom_buddypress_member_xprofile_custom_fields', 20 );
January 30, 2019 at 12:47 #4935@themosaurus- 1 Topics
- 1675 Posts
Hi @malasreda,
To fix this, you just need to do the same as described in my previous post in this topic.
In your case that means you have to replace that line:
$vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id() );
By this one instead:
$vos_fantasmes = xprofile_get_field_data( 'Vos fantasmes', bp_get_member_user_id(), 'comma' );
Hope this fixes your issue.
Best regards,
January 30, 2019 at 14:57 #4956 -
AuthorPosts
Hi there,
This topic has been inactive for a while now so we will be closing it to keep the forum tidy. Don't hesitate to create a new topic if you still need help and we'll be glad to help you!
Best regards,
The Themosaurus team.
The topic ‘Display City on User Profile’ is closed to new replies.