Find Answers and Get Support › Forums › Gwangi – PRO Multi-Purpose Membership, Social Network & BuddyPress Community Theme › Compatible Plugins › BP Profile Search › City, member type and member description on BP Profile search directory card
- This topic has 8 replies, 2 voices, and was last updated 6 years ago by
Themosaurus.
-
AuthorPosts
-
JossParticipant@joss
- 34 Topics
- 85 Posts
Hi Themosaurus,
I read in your forum that you make us a code snippet to display what we want on card member directory, and suddenly on profile member.
I want to display : Member Type and City and also Profile Description instead activity (in your demo).
Please have a look at the screenshots.My register page :
https://www.partagemon4pattes.com/inscription/Thanks for your help,
JossJanuary 30, 2019 at 12:07 #4930@themosaurus- 1 Topics
- 1675 Posts
Hi @joss,
Yes, we always try our best to help and sometimes we provide small code snippets to help out our members whenever we can. However, please note that we provide code snippets as a courtesy and we do not provide theme customization, so we will always try our best but please understand that you shouldn’t expect too much.
That being said:
1. Here is a code snippet to display the Member Type and City in your profile cards:
add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_buddypress_member_type', 10 ); function gwangi_buddypress_member_type() { $member_type_name = bp_get_member_type( bp_get_member_user_id() ); $member_type = bp_get_member_type_object( $member_type_name ); ?> <div class="bp-member-xprofile-custom-field bp-member-type"><?php echo $member_type->labels['singular_name']; ?></div> <?php } if ( ! function_exists( 'gwangi_buddypress_member_city' ) ) : /** * Print the HTML for the City XProfile Field in the BP Member Directory. * * @since 1.0.0 */ function gwangi_buddypress_member_city() { if ( function_exists( 'xprofile_get_field_data' ) ) : $city = xprofile_get_field_data( 'City', bp_get_member_user_id() ); $allowed_html = array( 'a' => array( 'href' => array(), 'rel' => array(), ), ); if ( ! empty( $city ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-city"><?php echo wp_kses( $city, $allowed_html ); ?></div> <?php endif; endif; } endif;
Don’t forget to change
'City'
by your own field name in this snippet.2. Unfortunately replacing latest activity with profile description is more complicated and we don’t have any snippet that we could share with you for that. If you are familiar with modifying themes, I can tell you that this is located in gwangi/buddypress/members/single/cover-image-header.php on line 131 in your Gwangi theme. Please be aware that if you do modify Gwangi, your modifications will be lost if you update it later. If you are not familiar with theme modifications, we recommend you to require the services from Envato Studio freelancers (https://studio.envato.com/explore/websites-programming). This web platform gives you access to developers who have already experience with theme customizations, and for very competitive prices.
3. Having the choice of displaying the first name and last name instead of the username is a feature that has already been requested and is currently on our roadmap, it will be implemented in a future update.
If you want that feature to be implemented you can show your interest to raise the priority of that feature in the following topic: https://support.themosaurus.com/forums/topic/replace-username-with-name-verified-member-is-mentioned-name-icon-symbol/
Best regards,
January 30, 2019 at 14:26 #4950JossParticipant@joss- 34 Topics
- 85 Posts
Thanks for your help !
1. Your code snippet don’t display Member Type on single profile, just on profile cards…?
2. City don’t work for me, I think it’s because I have BP xProfile Location plugin installed for working with BP Maps for Members, do you have a solution for me please ?
Thanks,
JossJanuary 30, 2019 at 17:55 #4979@themosaurus- 1 Topics
- 1675 Posts
Hi @joss,
Glad we can help 🙂
Ok if you have BP xProfile Location then the snippet is indeed different.
I also modified it to display the member type on profile page header too.Can you please try to replace the previous snippet by the following one?
add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_buddypress_member_type', 10 ); function gwangi_buddypress_member_type() { if ( bp_is_user() ) { $user_id = bp_get_displayed_user()->id; } else { $user_id = bp_get_member_user_id(); } $member_type_name = bp_get_member_type( $user_id ); $member_type = bp_get_member_type_object( $member_type_name ); ?> <div class="bp-member-xprofile-custom-field bp-member-type"><?php echo $member_type->labels['singular_name']; ?></div> <?php } if ( ! function_exists( 'gwangi_bp_xprofile_location_member_location' ) ) : /** * Print the HTML for BP xProfile Location Field in the BP Member Directory. * * @since 1.1.9 */ function gwangi_bp_xprofile_location_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 ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $location, $allowed_html ); ?></div> <?php endif; endif; } endif;
Don’t forget to replace
'Location'
by the name of your location field.Also, if you are happy with Gwangi so far, feel free to review our theme on ThemeForest. Each review is greatly appreciated as it helps us grow on the platform and allows us to improve the quality of our products, bring new features and make even more awesome themes! To do so, it is very simple: go to your ThemeForest downloads page (https://themeforest.net/downloads), find Gwangi and click on the stars. Thank you! ?
Best regards,
January 31, 2019 at 11:49 #4986@themosaurus- 1 Topics
- 1675 Posts
Hi @joss,
There is no easy way to display only the city, but it is possible to display the city and postal code.
Please try to replace the second part of the snippet by the following:if ( ! function_exists( 'gwangi_bp_xprofile_location_member_location' ) ) : /** * Print the HTML for BP xProfile Location Field in the BP Member Directory. * * @since 1.1.9 */ function gwangi_bp_xprofile_location_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 ) ) : $location_parts = explode( ', ', $location ); if ( ! empty( $location_parts[1] ) ) : ?> <div class="bp-member-xprofile-custom-field bp-member-location"><?php echo wp_kses( $location_parts[1], $allowed_html ); ?></div> <?php endif; endif; endif; } endif;
Best regards,
February 1, 2019 at 11:33 #5021@themosaurus- 1 Topics
- 1675 Posts
February 1, 2019 at 18:01 #5026 -
AuthorPosts
The topic ‘City, member type and member description on BP Profile search directory card’ is closed to new replies.