Tagged: code
Just have added one. Thank you for your quick reply.
Hi Tosin,
about your last question.It is difficult to disable based on the member types as the member type is registered too late.
Ravi & I looked at it and we found that we can disable the component conditionally but not using member type as context./ if using the user roles as context will work for you please let us know and we will post the code.
Thank you
BrajeshOk this will work, all I have to do is create a new custom user role and automatically assign the role with the necessary member types. So when a new user registers as either a brand or business his role will automatically be registered as the custom role. You can paste the code.
Thank you very much for your help I really appreciate your effort.
Hi Tosin,
Here is an example
/** * Disable BuddyPress Components conditionally based on role. * * @param bool $enabled is component enabled? * @param string $component BuddyPress Component id(e.g 'activity', 'groups', 'notifications', 'friends', 'settings', 'xprofile', 'messages', etc) * * @return mixed */ function buddydev_conditionally_disable_components( $enabled, $component ) { if ( ! is_user_logged_in() ) { return $enabled; // we do not disable component for the logged in user } $user = wp_get_current_user(); $roles = $user->roles ; // $role check for 'subscriber', 'contributor', 'author', 'editor', 'administrator' if ( 'friends' == $component && in_array( 'subscriber', $roles ) ) { //disable friends for subscribers $enabled = false; } return $enabled; } add_filter( 'bp_is_active', 'buddydev_conditionally_disable_components', 10, 2 );
Submit
Please feel free to modify and adapt it as per your requirements.
Hope it helps.
Regards
Brajesh
The topic ‘ [Resolved] Remove add friend button for member type on members page/members loop’ is closed to new replies.