Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wbcomdev/dc081020c51afcff62cda5856666157f to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/dc081020c51afcff62cda5856666157f to your computer and use it in GitHub Desktop.
/**
* Hide add friend button for specific members type.
*/
function wb_hide_add_friend_button_from_members_types( $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 );
// please mention here the member type to hide the add friend button.
$members_types_to_hide_add_friend_button = array( 'demo-member-type', 'member-type-second' );
if ( ! in_array( $member_type, $members_types_to_hide_add_friend_button, true ) ) {
return $button;
}
return '';
}
add_filter( 'bp_get_add_friend_button', 'wb_hide_add_friend_button_from_members_types' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment