BuddyDev

Search

[Resolved] Add button in member directory.

  • Participant
    Level: Initiated
    Posts: 13
    Christian22 on #45439

    Hello Buddypress

    – We want to add a “VIEW PROFILE” button on the user’s profile in the buddypress member directory. Which will display the user’s profile page after the click.
    – And another button “CONTACT” which will redirect to a specific tab of the user’s profile.
    Exactly like the “add as friend” button, “siganle” etc.

    Can you give us a code for this please?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #45444

    Hello Christian,

    Thank you for posting. Please let me know which theme and BuddyPress template pack you are using so that I can help.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 13
    Christian22 on #45447

    Hello Ravi,
    Thank you for the feedback
    the theme: https://themeforest.net/item/rehub-directory-multi-vendor-shop-coupon-affiliate-theme/7646339)
    Buddypress version 10.3.0

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #45448

    Hello Christian,

    Try the following code:

    
    
    add_action( 'bp_directory_members_actions', function () {
    	$member_id = bp_get_member_user_id();
    
    	if ( ! $member_id || ! bp_is_members_directory() ) {
    		return;
    	}
    
    	$user_domain = bp_core_get_user_domain( $member_id );
    
    	if ( bp_is_active( 'xprofile' ) ) {
    		$profile_link = $user_domain . bp_get_profile_slug();
    
    		echo sprintf( '<div class="generic-button"><a href="%s">%s</a></div>', esc_url( $profile_link ), esc_html__( 'View Profile' ) );
    	}
    
    	echo sprintf( '<div class="generic-button"><a href="%s">%s</a></div>', esc_url( $user_domain ), esc_html__( 'Contact' ) );
    } );
    
    

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 13
    Christian22 on #45449

    THANK YOU RAVI,
    That’s great.
    it’s working fine so far.

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2908
    Ravi on #45456

    Hello Christian,

    Thank you for the acknowledgement. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Add button in member directory.’ is closed to new replies.

This topic is: resolved