I’m note sure how your custom roles were created, so I can’t tell you how to figure out if the current user is one or the other, but basically, you’ll be using code like this:
function bpcodex_remove_member_tab_on_role() {
$role = 'owner;
if ( 'owner' == $role ) {
bp_core_remove_nav_item( 'messages' );
bp_core_remove_nav_item( 'friends' );
}
}
add_action( 'bp_actions', 'bpcodex_remove_member_tab_on_role' );
note that this will not work as is–you need to be able to get the current user’s role, dependent on how you’re doing that. However, the simpler answer is that if you’re not using the friends and messages components, just turn them off in the BuddyPress settings in wp-admin.
Thanks David, but I have found another cool solution. It’s not Pet Owner and Pet Groomer anymore though.
Hope it helps other people, too!
**
* Remove certain tabs from user profile based on member role.
*/
function buddydev_remove_tabs_based_on_member_roles() {
if ( ! bp_is_user() ) {
return;
}
$premium_dog_owner = bp_current_user_can( 'premium_dog_owner' );
$premium_dog_borrower = bp_current_user_can( 'premium_dog_borrower' );
$premium_user = ($premium_dog_owner ? : $premium_dog_borrower);
if ( ! $premium_user ) {
bp_core_remove_nav_item( 'friends' ); //removes the tab friends
bp_core_remove_nav_item( 'messages' ); //removes the tab messages
bp_core_remove_nav_item( 'reviews' ); //removes the tab reviews
}
}
add_action( 'bp_setup_nav', 'buddydev_remove_tabs_based_on_member_roles', 1001 );