Disable WordPress dashboard for subscribers

There’s sometimes scenarios where you want to disable the WordPress dashboard for certain users such as subscribers. You may also want to disable the admin bar for subscribers too.

This isn’t an uncommon scenario, this post tells you how to both disable the WordPress Dashboard for subscribers and disable the admin bar.

Adding the action

If you’re developing a WordPress theme, you are more than likely familiar with WordPress’ actions and hook mechanism.

We’re essentially going to add a new action to the admin init in order to achieve our objective of disabling the WordPress dashboard for subscribers. Add this to your functions.php file:

add_action('admin_init', 'disable_dashboard');

function disable_dashboard() {
    if (current_user_can('subscriber') && is_admin()) {

The above code will redirect subscribers to the home page. You could redirect to any page on your site here.

Disable WordPress dashboard for all but administrators

You may want to disable the dashboard for anyone who isn’t an administrator. You can achieve this with:

add_action('admin_init', 'disable_dashboard');

function disable_dashboard() {
    if (!is_user_logged_in()) {
        return null;
    if (!current_user_can('administrator') && is_admin()) {

Notice this time I’m returning null for when users are not logged in. This is to ensure that admin-ajax.php still works for logged out users, otherwise it tries to redirect.

That’s pretty much it. Very straight forward. You could also target specific capabilities instead of for user roles, a full list can be found on the WordPress codex.

Hiding the admin bar for subscribers

Aside from disabling the dashboard, you might want to also hide the admin bar for subscribers too. Simply add the following action to your functions.php file:

add_action('admin_init', 'disable_admin_bar');

function disable_admin_bar() {
    if (current_user_can('subscriber')) {

As with before, it is possible to switch ‘subscriber’ for any user type or capability. As with before, the WordPress Codex has a full list of capabilities to target.

That’s essentially it. If you have any questions or feedback, feel free to leave a comment below.


Web Developer living in Manchester, working for Studio Skylab (http://www.studioskylab.com). Views and thoughts are my own.

You may also like...

27 Responses

  1. Marion says:

    if (current_user_can(‘subscriber’) && is_admin()) {
    Why && is_admin? is he a subscriber or an admin? i don’t get the logic, can you explain it?

    • Ste says:

      Hi Marion. is_admin() is one of those WordPress functions which I feel is poorly named. is_admin() actually checks to see if you’re in the WordPress dashboard rather than being a role related check. I personally think ‘is_dashboard()’ would have been a better name.

  2. Cathy says:

    Thank you so much for this post- I’ve been looking for this information for weeks!

  3. Cathy says:

    Wow that would wonderful!! One issue I see popping up a lot is the use of username by WP and Buddypress and the inability to control if display name or full name is shown instead of username on various posts and user profiles (Maybe what I mean is a way to switch nicename from username to display name or full name?).

  4. Cathy says:


  5. Cathy says:

    Hope you have a great New Year! Sorry to trouble you with questions, but I am not sure if I am using this code correctly. I was testing all of my buttons and I realized that a non-admin user will still be directed to the profile section of the WP dashboard if he/she resets a password with the WP reset password link (user enters email then clicks link in email, resets password, then clicks login link to log in with new password, login takes user to WP profile). Do I need to change something to have user redirected to a custom page (home, buddypress profile, etc)?

    Thanks so much!


  6. Igor Skoldin says:

    You need to add a check if this is an ajax request to the disable_dashboard function, otherwise you will get the homepage html as reponse for all your frontend ajax requests.

    wp_redirect(home_url())); in the disable_dashboard function has too many braces, should be wp_redirect(home_url())

  7. Igor Skoldin says:

    You should also use the ‘init’ hook instead of ‘admin_init’ for your disable_admin_bar function if you want to disable it on the frontend.

  8. Cathy says:

    Thanks for the tips!

  9. Mark says:

    This doesn’t disable the dashboard for subscribers, it redirects them from it.

    Why reinvent features such as the profile page when you can merely hide the portions of the dashboard you don’t want the non-admins to reach?

  10. Great post, thanks for those snippets code. You have a small typo error in your code «wp_redirect(home_url()));» should be «wp_redirect(home_url());»

  11. Tanaka says:

    Hi Igor,

    Could you show the new code here? Author’s code not working or have mistakes.

  12. maarten says:

    Doesn’t work for me. After pasting the code in the functions.php file, the whole site is ‘white’. Nothing on the screen. (I’m and administrator)

    • Silva says:

      Hey it broke your theme, wp_redirect(home_url()); paste this in the original position, the original has one to many braces

  13. maarten says:

    Ok, for others: There’s a small typo error in the code «wp_redirect(home_url()));» should be «wp_redirect(home_url());»
    After that, it worked for me.

  14. billy says:

    your code: add_action(‘admin_init’, ‘disable_dashboard’);

    function disable_dashboard() {
    if (!is_user_logged_in()) {
    return null;
    if (!current_user_can(‘administrator’) && is_admin()) {

    has too many “)” on the wp_redirect(home()); line.

  15. Thanks for the code!
    Just a little reminder that there is still one closing parenthesis too much which will cause 500-er error in the first function.

  16. Doesn’t work on the TwentyFourteen WP theme. Dashboard works the same as always.

  17. rvghoghari says:

    Its not a proper solution, Because of your code is blocked admin ajax request.

    Use below code.

    add_action(‘admin_init’, ‘disable_dashboard’);

    function disable_dashboard() {
    if (!is_user_logged_in()) {
    return null;
    if (!current_user_can(‘administrator’) && is_admin() && !wp_doing_ajax()) {

  18. Alternatively, you can use the Admin Bar & Dashboard Control plugin, by Collins Agbonghama.

  19. coder618 says:

    if any one use this two condition (!current_user_can(‘administrator’) && is_admin()),
    this will BLOCK any ajax request if user is not an administrator.

  1. 24th October 2017

    […] Lock Non-Administrators out of the Dashboard If you’re allowing customers to have their own accounts on your site, it’s a good idea to ensure that they can’t access the WordPress Dashboard.  Even though a customer’s role means that can’t do any damage, it’s still good practice to keep them out. You can accomplish this through a plugin like Remove Dashboard Access or through some simple code. […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.