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?
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');
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.
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.
If your SEO page menu is redirecting to 'admin.php?page=wpseo_workouts'
The below code worked for me. here I am hiding the SEO menu for our custom user(non-admin). you can remove if condition.
add_action( 'admin_init', 'my_remove_menu_pages' ); function my_remove_menu_pages() { global $user_ID; if ( $user_ID == 13 ) { //your user id remove_menu_page('wpseo_workouts'); } }