HowTo: Disable Access to the WordPress Dashboard for Non-Admins

Update: I had a few requested to bundle this into a plugin so I did. You can download it here.

Currently, I’m working on a site where we didn’t want non-admins to even be able to access the wp-admin dashboard. I searched around quite a bit looking for a complete shutoff-solution but most of the results detail how to literally disable the “Dashboard” menu in wp-admin.

Finally, trolling the comments on a like-solution in a post by c. bavota, I stumbled across a simplified version of bavotasan’s function that does exactly what I want, plus it redirects unworthy users to the homepage!

The simplified function was authored by somebody going only by the moniker of Jake.

It’s a pretty simple solution. It adds an action calling a function called ‘redirect_dashboard’ which checks the user level, and if the currently-logged-in-user is unworthy, they get bounced to the homepage. Pretty neat. On line #4, the function checks the user level, with the default set as ‘level_10′ or administrator. I modified this to ‘level_7′ to exclude anyone below the Editor level, but you could choose whichever capability level suits your purpose. Vist the Roles and Capabilities Codex page to find out more about user levels.

Here’s the snippet (which should be added to your theme’s functions.php file)

add_action('admin_init', 'no_mo_dashboard');
function no_mo_dashboard() {
  if (!current_user_can('manage_options') && $_SERVER['DOING_AJAX'] != '/wp-admin/admin-ajax.php') {
  wp_redirect(home_url()); exit;


  1. I love this plugin

  2. @TheBlogTech Glad to hear it’s working for you.

  3. I do like this plugin, it’s redirect unworthy users to the homepage.

  4. I am not aware of this and thanks for letting us know about this…Great job!!

  5. This is “almost ” perfect for me. Can i add user level Author to the allow list? I’m not a coder and have no idea about the syntax.



  6. This is “almost ” perfect for me. Can i add user level Author to the allow list? I’m not a coder and have no idea about the syntax.


  7. Actually would this work????

    add_action(‘admin_init’, ‘no_mo_dashboard’); function no_mo_dashboard() { if (!current_user_can(‘edit_published_posts’) && $_SERVER[‘DOING_AJAX’] != ‘/wp-admin/admin-ajax.php’) { wp_redirect(site_url()); exit; } }

    • @mananamas Yes, that should work. Just remember that any user that has that capability will still have access to your dashboard. It will not longer just be admin users.

      • hey drew!!!
        this function worked fine for me but u know i added the post href in one of the pages inside wordpress so that we could see the post .it doesn’t do it can u give me a possible solution

  8. Hi, just would like to point out redirecting to site_url would point to the wordpress directory. for sites with a separate wordpress folder, users will land in a 404 page. use home_url instead.

  9. Awesome, exactly what I was looking for, thank you!

  10. Does this also disable access to wp-login as well?

    I really hate that ugly login.

    • Drew

      June 9, 2012 at 8:13 pm

      Unfortunately, no, though that feature may be added in a future release. Perhaps a front-end login that’s style-able.

  11. Nice snippets! thank you for share

  12. Thank you for this!

  13. Nice peace of code! Thanks a lot, it’s great! :)

  14. Christian Philippsen

    September 11, 2012 at 2:20 am

    Thank you for this. This is working great alongside my auth_redirect function :)

  15. Awesome! Does the trick nicely without a plugin

  16. Hey Drew! Working on a project and stumbled across this. Works perfectly. Thanks!

    • Drew

      April 8, 2013 at 11:26 pm

      Jeremy: Did you use the snippet or the plugin? The plugin got a little bloated b/c people were asking for configurable options, but it functions basically the same.

  17. I tried your snippet to redirect to the articles admin page, using admin_url(‘edit.php’) instead of home_url(), but it starts an infinite redirect loop.

    So I tried with the wp_dashboard_setup hook, and it seems to work well:

    function redirect_from_dashboard() {
    	if (!current_user_can('manage_options')) {
    		wp_redirect(admin_url('edit.php')); exit;
    add_action('wp_dashboard_setup', 'redirect_from_dashboard');
  18. Does anybody have an example of how this might be used to redirect non-admins back to their current page? So if they log in on the home page widget, the home page is reloaded upon login or if they login on the login page, that page is reloaded.

  19. Awesome post, saved me having to look into writing this from scratch. it also goes nicely with:

    // show admin bar only for admins
    if (!current_user_can('manage_options')) {
    	add_filter('show_admin_bar', '__return_false');
    • Thanks Drew for your Snippet!
      @ Scott Flack:
      Your snippet is awesome to hide the admin bar. Thanks as well.

      But be aware: if you don’t use Drew’s Snippet, someone could enter the admin area. In fact by just adding “/wp-admin” to the URL of your website. (

      So I used both of your snippets. :)

  20. Wanted this single long time! It’s working on my blog too!

  21. You absolute legend – thank you

  22. Thanks so much!!
    I used this on
    So check it out ;)

  23. Just wanted to say thank you so very much. I hate to install a plugin for something that can be done so simply. Thanks again!

  24. I have a problem with this. I don’t want other users than admins to see the Dashboard. Ok your plugin does work, it removes the Dashboard, however no other users than admins will be able to add a new POST. How can this be solved?

    • Drew Jaynes

      June 11, 2014 at 1:03 am

      Out of curiosity … how do you plan to let users post if you don’t want them to be able to access the back-end?

      • I’m a total beginner of WordPress, I’ve just setup my first blogsite for my company and I want the bloggers to be able to post without seeing either the Dashboard nor the Admin menu, I just need a button or link which enables them to make a new post and of course comment each post. None of the bloggers are interested in the Dashboard or Admin menus. I want a normal webside on the internet with possibilites to make posts and comment these. Is WordPress the tool for me, or should I go in another direction?

  25. Nice snippet, love it so much! Thanks

Leave a Reply

© 2014 WerdsWords

Theme by Anders NorenUp ↑