Hiding the WordPress Dashboard for Non-Admin Users
by Bandicoot Marketing on | 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'); ?>
29 comments for “Hiding the WordPress Dashboard for Non-Admin Users”