Admin bar visible for subscribers
-
Hi, I have set the option in the plugin settings “Show Admin Bar” to Administrators, Editors and Authors. However, it still shows for Subscribers.
I also have set “Admin area access” to Default. I have also tried every other combination and nothing works.
The only way I could get it to be hidden was with a custom function:
// show admin bar only for admins and editors
if (!current_user_can('edit_posts')) {
add_filter('show_admin_bar', '__return_false');
}Unfortunately that code above only hides the admin bar, so I can still get to the dashboard by URL. So I added the below function to actually disable it. However, now editing posts on the frontend shows a warning message.
// Disable admin for subscribers
add_action('admin_init', 'disable_dashboard');
function disable_dashboard() {
if (current_user_can('subscriber') && is_admin()) {
wp_redirect(home_url());
exit;
}
}I’d prefer it if your plugin handled this as now I’m wondering why it didn’t work in the first place and whether I’d be causing some sort of conflict by adding extra functions.
Please advise how to get the settings working please. Thanks
The topic ‘Admin bar visible for subscribers’ is closed to new replies.