0

I don't want this shown to members who register for my website as it's confusing and irrelevant for them.

I assume some code added to functions.php will do the trick but what code?

4

This should hide it for everyone but the admin. If you run into any issues, you can use a plugin like Advanced Access Manager to get the job done. With that you will have more control of what each user level has access to.

function hide_yoastseo() {
if ( !current_user_can( 'administrator' ) ) :
    remove_action('admin_bar_menu', 'wpseo_admin_bar_menu',95);
    remove_menu_page('wpseo_dashboard');
endif;
}
add_action( 'admin_init', 'hide_yoastseo');
0

Not sure about Yoast SEO but this is what I use for non admin users:

function my_remove_menu_items() {
if ( !current_user_can( 'administrator' ) ) : // IF NON ADMIN USER
    //remove_menu_page( 'index.php' ); // DASHBOARD
    //remove_menu_page( 'edit.php?post_type=custom_post_type' ); // CPT
    //remove_submenu_page( 'edit.php?post_type=custom_post_type', 'post-new.php?post_type=custom_post_type' ); // CPT SUB MENU
    //remove_menu_page( 'edit.php' ); // POSTS
    //remove_menu_page( 'upload.php' ); // MEDIA
    //remove_menu_page( 'edit-comments.php' ); // COMMENTS
    //remove_menu_page( 'edit.php?post_type=page' ); // PAGES
    //remove_menu_page( 'plugins.php' ); // PLUGINS
    //remove_menu_page( 'themes.php' ); // APPEARANCE
    //remove_menu_page( 'users.php' ); // USERS
    //remove_menu_page( 'tools.php' ); // TOOLS
    //remove_menu_page( 'options-general.php' ); // SETTINGS
endif;
}
add_action( 'admin_menu', 'my_remove_menu_items' );

Obviously, this goes in your functions.php and you uncomment what you want to hide.

Hope this is a good starting point, Ian.

0

I used:

function hide_yoastseo() {
if ( !current_user_can( 'administrator' ) ) :
    remove_action('admin_bar_menu', 'wpseo_admin_bar_menu',95);
    remove_menu_page('wpseo_dashboard');
endif;
}
add_action( 'admin_init', 'hide_yoastseo');

... but then the media library in grid view did not load and I could not add a featured image. Then I changed 'admin_init' to 'admin_menu' and it resolved the media library grid view problem.

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.