Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Remove add friend button for member type on members page/members loop


  • teeboy4real
    Participant

    @teeboy4real

    Hi, I want to remove the ‘add friend’ button for a specific member type in my buddypress site on the members page. I don’t want them to have friend requests from anyone.

    I tried this code provided by @henrywright but it only works for the individual members page and not the members loop. After applying the code to bp-custom.php file the add friend button still shows on the member’s page.

    The idea is that I have a member type called business and it would not make sense to add a business as a friend but you can only follow a business.

    function browserco_filter_add_friend_button( $button ) {
        $member_type = bp_get_member_type( bp_displayed_user_id() );
        if ( 'business' !== $member_type ) {
            return $button;
        }
        return '';
    }
    add_filter( 'bp_get_add_friend_button', 'browserco_filter_add_friend_button' );

    Please can anyone help with this?

Viewing 1 replies (of 1 total)

  • teeboy4real
    Participant

    @teeboy4real

    Problem solved

    Solution provided by buddydev.com

    Paste the following code in your bp-custom.php file

    
    function buddydev_hide_add_friend_button( $button ) {
    
    	$displayed_user_id = bp_displayed_user_id();
    
    	$user_id = ( $displayed_user_id ) ? $displayed_user_id : bp_get_member_user_id();
    
    	$member_type = bp_get_member_type( $user_id );
    
    	if ( 'business' !== $member_type ) {
    		return $button;
    	}
    
    	return '';
    
    }
    add_filter('bp_get_add_friend_button', 'buddydev_hide_add_friend_button');
Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Remove add friend button for member type on members page/members loop’ is closed to new replies.
Skip to toolbar