1


I need to show BuddyPress menu item just specific roles and hide all other users.
I have 2 user roles like subscriber and author.
For example; I want to show my friends only to the authors and to me. None of the other subscribers can see.

I can hide menu items with this code in functions.php ;

function bp_remove_nav_item() {
    global $bp;    
    bp_core_remove_nav_item( 'buddyblog' );
    }
add_action( 'wp', 'bp_remove_nav_item' );

How can I edit this for excepting to me and the authors ?

2

I solved it with my own effort.

function bp_remove_nav_item() {
    global $bp;
    $current_user   = wp_get_current_user();
    $role_name      = $current_user->roles[0];
    if($role_name==='administrator'){
    bp_core_remove_nav_item( 'buddyblog' );
    }
}
add_action( 'wp', 'bp_remove_nav_item' );

This code delete blog menu for administrator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.