Support only during business hours : Monday to friday, from 8:30 am – 5:30 pm CEST

Due to the decrease in our staff due to vacations, our response time may be longer.

Be sure we're doing our best to manage your topic as soon as possible.

City, member type and member description on BP Profile search directory card

This topic is resolved
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • Joss
    Participant
    • 34 Topics
    • 85 Posts
    @joss

    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,
    Joss

    Joss
    Participant
    • 34 Topics
    • 85 Posts
    @joss

    Another thing,

    On my members profiles, it display just user id instead the name of member, I would like “Nom” and “Prénom”.
    I think it’s in the same code snippet like my my previous request.

    Thanks,
    Joss

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1675 Posts
    @themosaurus

    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,

    Joss
    Participant
    • 34 Topics
    • 85 Posts
    @joss

    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,
    Joss

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1675 Posts
    @themosaurus

    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,

    Joss
    Participant
    • 34 Topics
    • 85 Posts
    @joss

    Great, it works !

    But now, is it possible to display only city and not all of the adress ?

    Thanks,
    Joss

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1675 Posts
    @themosaurus

    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,

    Joss
    Participant
    • 34 Topics
    • 85 Posts
    @joss

    Yes it’s work, you’re the best !!

    Themosaurus
    Keymaster
    Themosaurus Support
    • 1 Topics
    • 1675 Posts
    @themosaurus

    You’re welcome @joss, glad we could help you! ?

    Best regards,

Viewing 9 posts - 1 through 9 (of 9 total)

The topic ‘City, member type and member description on BP Profile search directory card’ is closed to new replies.

Troubleshooting Demo Imports

You're trying to setup your theme but you're experiencing errors when importing the demo content? Or you've just followed the setup guide but your website doesn't look exactly like our demo? These are common issues for which you can find easy and quick fixes.

Happy With our Support So Far?

Feel free to review our theme on Themeforest! It helps us making our products more known to new potential customers, which allow us more time to improve the quality and develop new features. #SharingIsCaring ❤️

Discover MatchPress

Skip • Like • Super-Like

Add powerful matching features like Member likes, skips, super likes, conditional private messaging and much more.

Setup Your Cera or Gwangi powered Community Website and Turn it into an iOS and Android App

15% discount for Cera users

To unleash the full power of your Cera or Gwangi theme, we have partnered with the Zipline team. Your community website can now be fully setup and turned into your very own custom app for iOS and Android.

Whether you've newly acquired the theme or already got your site up and running, Zipline got you covered. And we got you an incredible discount.

Holiday, Weather & Festive effects
to pimp your WordPress Site