English flagItalian flagKorean flagChinese (Simplified) flagChinese (Traditional) flagPortuguese flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroatian flagDanish flagFinnish flagHindi flagPolish flagRomanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flagAlbanian flagEstonian flagGalician flagMaltese flagThai flagTurkish flagHungarian flagBelarus flagIrish flagIcelandic flagMacedonian flagMalay flagPersian flag

Hide The WordPress Dashboard and wp-admin COMPLETELY!


WordPress 3 Compatible

I have seen several plugins that “hide” the dashboard from subscribers, but none that functions as I want.
I don’t want it to allow only the tools, and profile page. I want it to straight kick the user out of the dashboard!

So, I wrote my own plugin that does that. If anyone that is not an admin (cannot activate plugins) attempts to access the dashboard via url or link, they are redirected to the front of the site. sorry, access denied..

Here is my code. Just drop this in your themes functions.php file and edit the url of the redirect to whatever you want.

{code type=php}
//hook onto dashboard and redirect all non admin to front site
add_action(“admin_init”,”redirect_nonadmin_fromdash”);
function redirect_nonadmin_fromdash(){
if (!current_user_can(‘activate_plugins’)) {
// Edit Line Below For Your Own Redirect
header( ‘Location: http://www.erikshosting.com’ ) ;
}
}
{/code}


10 Comments

  1. Excellent decision! Been looking for and then you helped me. Realized directly on the site. Immediately save 4 MB memory on the server!

  2. Great Stuff!
    is there away to allow dashboard access to the editor role as well?

    1. Yah,
      simply swap the part that says if (!current_user_can('activate_plugins'))
      with this:
      if (!current_user_can('publish_posts'))

      Thats it!

  3. I don’t want my users kicked out of the dashboard. I just want some widgets to be removed off of it. Is that possible??

  4. PERFECT! Changed a couple little things but this is perfect! Thanks.

  5. Hi,

    Can we hide through .htaccess file I have read that but when I do that its not working if you have any idea for that

    Thanks

  6. How to redirect them when login to the latest visited page, such as get_permalink()?

  7. I want specific about this

  8. Great trick
    nice work!!

Leave a Reply