Hiding the WordPress Dashboard for Non-Admin Users
by c.bavota | Posted in Tutorials | 29 comments
There are two plugins out there that I have found that help customize your WordPress install by removing the dashboard. Why would you want to do this? Well, perhaps you have installed and customized WordPress for a client who really doesn’t need the dashboard, or you don’t want users who login to see the dashboard. Either way, there are options. Something like this is best left to a plugin so that when you upgrade is still functions and you don’t have to go in and change everything.
Deep Wave has created a plugin called Hide Dashboard. It allows Admins to see the dashboard and removes it for regular users. There are a few options like allowing Authors and Editors to see the dashboard. I tried using this plugin on WordPress 2.7 and it did remove the dashboard for non-Admin users, but when they logged in it brought them straight to the dashboard even though the link was removed. Not really what you want.
Il Filosofo created a small plugin called Remove the Dashboard which worked great but hasn’t yet been updated for 2.7. I went in and made a few changes to get it to do what I wanted. Here is the original plugin code written by Austin Matzko and full credit is given to him for figuring it all out.
<?php
/*
Plugin Name: Filosofo Remove Dashboard
Plugin URI: http://www.ilfilosofo.com/blog/
Description: Make the Dashboard, that page that takes forever to load when you log in, disappear.
Version: 1.0
Author: Austin Matzko
Author URI: http://www.ilfilosofo.com/blog/
*/
/* Copyright 2006 Austin Matzko (email : if.website at gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function remove_the_dashboard () {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);
if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]);
reset($menu); $page = key($menu);
while (!$the_user->has_cap($menu[$page][1]) && next($menu))
$page = key($menu);
if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]))
wp_redirect(get_option('siteurl') . '/wp-admin/' . $menu[$page][2]);
}
add_action('admin_menu', 'remove_the_dashboard');
?>
I made some minor changes so that now it works in WordPress 2.7 and Admins have the ability to view the dashboard when they login.
<?php
/*
Plugin Name: Filosofo Remove Dashboard
Plugin URI: http://www.ilfilosofo.com/blog/
Description: Make the Dashboard, that page that takes forever to load when you log in, disappear.
Version: 1.0
Author: Austin Matzko
Author URI: http://www.ilfilosofo.com/blog/
*/
/* Copyright 2006 Austin Matzko (email : if.website at gmail.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
Update 12/12/2008
Modified by c.bavota of http://bavotasan.com for WordPress 2.7 and to allow the dashboard for Admins.
*/
function remove_the_dashboard () {
if (current_user_can('level_10')) {
return;
} else {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);
if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]);
reset($menu); $page = key($menu);
while (!$the_user->has_cap($menu[$page][1]) && next($menu))
$page = key($menu);
if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]))
wp_redirect(get_option('siteurl') . '/wp-admin/post-new.php');
}
}
add_action('admin_menu', 'remove_the_dashboard');
?>



Word of warning. Do not use the auto-install function for WordPress 2.7 with the revamped plugin zip file. The file was created on a Mac and it does some pretty funky things when installed automatically through the new 2.7 backend interface. I am looking into the reason but for now please install it the old fashion way, ie. unzipping it and uploading it through ftp.
it’s because of mac’s way of storing metadata for files. Apparently apache reads ._ and displays it at the top of . Basically, enable “view hidden files” and look for the ._, delete them, and then re-zip the plugin and it’ll be nice and smooth, no funky characters.
Hi I have a site im working on and i dont want people who register on my site to know its a wordpress site, I have a theme editor and made it look like its on my site but by the picture image it says dashboard, is there a way i can remove that option for subscribers?
cheers, nathan
I’m glad you’re able update the code for your purposes. I wrote the original code back in the day because the Dashboard used to take forever to load all those blog entries; every log-in could hang for 20 seconds or more.
Nowadays the feeds are loaded asynchronously, so it’s not so much of an issue.
Hey, do you know how hard it would be to create a plug-in to hide the various submenus in the dashboard such as:
Tags
Categories
Excerpt
Send Trackbacks
Custom Fields
Discussion
Post Arthur
I have a public blog site and I only want these options to be visible to people with an Editor status or above.
Hey thanks, this does what I need. FYI, I ended up changing the redirect line to:
wp_redirect(get_option('siteurl') . '/wp-admin/profile.php');as I require membership to post comments, but membership doesn’t entail the ability to make a new post (so I was getting access denied messages.)
@belsamper: I needed the exact change so you saved me time figuring out where to put it. Thanks for posting.
Awesome. Thanks for the fix. This is extremely useful.
I simplified it like this to send non-admin to homepage:
add_action('admin_menu', 'redirect_dashboard');
function redirect_dashboard(){
if( !current_user_can('level_10') ){
if( preg_match('#wp-admin/?(index.php)?$#', $_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]) )
wp_redirect(get_bloginfo('url'));
}
}
It is good information!
Is it possible with the same trick to remove also that damn “Tools” link?
I’m try to do the same thing.
add_action('admin_head', 'wphd_hide_tool_link', 0);function wphd_hide_tool_link() {
if (!current_user_can('edit_others_posts')) {
echo "\n" . '<style type="text/css" media="screen">#menu-tools { display: none; }</style>' . "\n";
}
}
this script hides tool menu link, but its accessible by a direct access. I’ve to manage to redirect to another page when somebody tries to access
The base I use is this one :
http://www.kpdesign.net/wp-plugins/wp-hide-dashboard/
In the arena of hiding or modifying dashboard and other admin menu items and ordering – I’ve just encountered the following beta.
Not yet quite right for hiding stuff from users – all changes are currently global, but if the blog is to be believed then role-based configurability is coming
http://w-shadow.com/blog/2008/12/20/admin-menu-editor-for-wordpress/
I’ve tested on a private site and it does exactly what it says on the tin
Great Post Thanks.
this is really good if you are looking for multi author blogs ,, thanks
I’m not sure what I’m doing wrong? I have taken the code placed it in a .php file and placed it in the plugin directory, but it is not showing up under the plugin menu. Am I missing something?
It worked itself out eventually. I’m not really sure why. But for any newbs such as myself if you place the file directly in the plugin folder it will work. I tried placing it in its own directory in the plugin folder as well but that did’nt work for me. Maybe it should work that way as every other plugin is in its own subdirectory?
Wow! This fix is awesome. Works like a charm. Thank you !
This is very hot information. I think I’ll share it on Facebook.
p.s. Year One is already on the Internet and you can watch it for free.
I was able to cludge this to remove Posts/Tools/Media by simply making these tweaks:
Duplicate the code three times in the .php file and revise each code area changing the words “blahblah” to the block you want removed.
function remove_the_blahblah () {while ((__('Blahblah') != $menu[$page][0]) && next($menu))
if (__('Blahblah') == $menu[$page][0]) unset($menu[$page]);
add_action('admin_menu', 'remove_the_blahblah');
Where “blahblah” is Media or Tools or etc… I’m my case I now have four blocks along with four add_action lines.
Someone can still go directly to the pages if they hand enter the path, but for me that’s not a problem. I just need to make it not visible and I’m good enough.
thank you for this little tool. very useful for my new client
Thank you! Works beautifully with 2.8.2.
Thanks for this post I was seeking the exact information that you provided here!
any word if this works on 3.0.3? I desperately need to remove some dashboard widgets for non-admin use
Great Job … Thanks man
Cool, that’s the fix I was looking for. Going to try this in 3.1, hope it works!
Thanks! This is exactly what I needed. Great job!
Thank you! most needed plugins for me.