When a subscriber logs in to your WordPress site, they usually see the admin bar at the top of the screen. This bar appears on the front end of the website. It gives links to the dashboard, profile, and other admin tools.
But in most cases, you don’t want subscribers to see the admin bar. You also don’t want them to access the WordPress dashboard. You only want them to stay on the front end and enjoy the content.
In this guide, you will learn how to:
- Remove the admin bar for subscribers
- Hide the dashboard for subscribers
- Control who sees the admin bar using user roles
You don’t need coding skills. Just follow the steps.
Why Hide the Admin Bar for Subscribers?
The admin bar is helpful for site owners, editors, and contributors. But for subscribers, it’s confusing.
They don’t need access to backend settings. They don’t need dashboard menus. They only want to log in and view protected content, or possibly update their profile.
Removing the admin bar gives a clean, simple look.
Method 1: Remove Admin Bar for Subscribers (Using Code)
This method is easy and safe. Add this code to your theme’s functions.php file:
add_action(‘after_setup_theme’, ‘remove_admin_bar_for_subscribers’);
function remove_admin_bar_for_subscribers() {
if (!current_user_can(‘edit_posts’)) {
show_admin_bar(false);
}
}
What this code does:
- It checks the logged-in user’s role.
- If the user can’t edit posts (like a subscriber), it hides the admin bar.
Save the file and log in as a subscriber. The admin bar will be gone.
Method 2: Use a Plugin to Hide the Admin Bar by User Role
If you don’t want to edit code, use a plugin.
Recommended Plugin:
Hide Admin Bar Based on User Roles
Steps:
- Go to Plugins > Add New
- Search for Hide Admin Bar Based on User Roles
- Install and activate the plugin
- Go to Settings > Hide Admin Bar Settings
- Select Subscriber (or any role you want)
- Save changes
Now, subscribers won’t see the admin bar.
Method 3: Redirect Subscribers Away from Dashboard
Even if the admin bar is hidden, subscribers can still go to the dashboard. You can stop that by redirecting them.
Add this code to your functions.php file:
add_action(‘admin_init’, ‘redirect_subscribers_away’);
function redirect_subscribers_away() {
if (!current_user_can(‘edit_posts’)) {
wp_redirect(home_url());
exit;
}
}
What this code does:
If a subscriber attempts to access the dashboard, they are redirected to the homepage.
You can change home_url() to any page you want. For example, send them to a welcome page or a member area.
wp_redirect(site_url(‘/welcome’));
Method 4: Use a Membership or Login Plugin
Some membership plugins include options to:
- Hide admin bar
- Redirect users after login
- Hide dashboard access
Examples:
- MemberPress
- Ultimate Member
- WP-Members
These plugins come with settings that allow you to control what different users can see. Great if you run a membership site or online course.
Method 5: Use CSS to Hide Admin Bar (Not Recommended)
You can use CSS to hide the admin bar, but it doesn’t stop dashboard access. Additionally, the admin bar continues to load in the background.
#wpadminbar {
display: none !important;
}
Add this to Appearance > Customize > Additional CSS.
This method is not secure. Use the code or plugin methods instead.
Block Dashboard Access Without Logging Out Users
Sometimes you want to block dashboard access but keep users logged in. This is helpful for membership sites.
Use this code:
add_action(‘admin_init’, ‘block_dashboard_access’);
function block_dashboard_access() {
if (!current_user_can(‘edit_posts’) && !wp_doing_ajax()) {
wp_redirect(home_url());
exit;
}
}
This works better with AJAX requests. It avoids issues with plugins or forms.