BuddyDev

Search

Replies

  • Participant
    Level: Enlightened
    Posts: 34

    Hi Brajesh,

    Thank you, it works fine now !

  • Participant
    Level: Enlightened
    Posts: 34

    Thnks thanks thanks Brajesh !!

    I should really learn PHP code.

    Thank you for all your help,

    Best,
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    You are the BEST Brajesh !!

    Thank you very much for your help !

    Just a last question : if I want to display one more level, how can I do this ?

  • Participant
    Level: Enlightened
    Posts: 34

    Hi Brajesh,

    I’m sorry, I don’t have any email notification for your reply…

    The ID is number 2.

    Thank you very much for your help !
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    Hi Brajesh,

    I don’t have any reply from you…

    Can you help me for this ?

    Thanks a lot,
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    Hi Brajesh,

    I want to display only Level 2, and not level 1 or 3.

    PMP Pro support team give me a code to display only the level I want on BP Profile page and I think you can adjust your code to make the same feature on BP directory. Look at the function $only_show on line 16.

    /*
    Remove "Membership Level" on the BuddyPress profile page, and instead only show the membership level name
    */
    
    function my_pmpro_bp_show_level_on_bp_profile() {
    	
    	if ( !function_exists('pmpro_getMembershipLevelForUser') ) {
    		return;
    	}
    	
    	$level = pmpro_getMembershipLevelForUser(bp_displayed_user_id());
    	
    	$show_level = get_option('pmpro_bp_show_level_on_bp_profile');
    	
    	//Only show for levels 1, and 2.
    	$only_show = array(2);
    	
    	if( $show_level == 'yes' && !empty( $level ) && in_array($level->id, $only_show)) {
    	?>
    	<div class="pmpro_bp_show_level_on_bp_profile">
    		<strong><?php echo $level->name; ?> </strong>
    	</div>
    	<?php
    	}
    }
    remove_filter( 'bp_profile_header_meta', 'pmpro_bp_show_level_on_bp_profile' );
    add_filter( 'bp_profile_header_meta', 'my_pmpro_bp_show_level_on_bp_profile' );

    Can you adjust your code to show only level 2 on my member directory ?

    Thank you Brajesh,
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    Yes, it works fine like this !!

    Do you know if I can display only level 1 or level 2 ?

  • Participant
    Level: Enlightened
    Posts: 34

    Brajesh,

    Your code display also membership level on BP profile page, and it not display the right level, do you know why ?

    Thanks,
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    Brajesh, you’re the best !!

    It works fine !

    If I want to display only one membership level, do you know how can I do this ?

    Thanks,
    Joss

  • Participant
    Level: Enlightened
    Posts: 34

    Thank you Brajesh 🙂

    Here the code snippet of my theme developer, it can help you…
    The first function is to display member type on BuddyPress directory profile informations AND user profile page. The second is to display Location from xprofile location, but I don’t use it. Theme developer sayed me : “Please also note that you don’t need to edit our snippet to achieve this as we recommend to add a new function to the following theme action: gwangi_buddypress_member_xprofile_custom_fields

    Code I use to display Member Type and Location that I don’t use :

    add_action( 'gwangi_buddypress_member_xprofile_custom_fields', 'gwangi_buddypress_member_type', 10 );
    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( 'Mon adresse', 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;