RENYUAN 2012-04-20
有时候为客户做后台不需要让非管理员用户看到 dashboard选项 及某些后台选项卡 如tools theme等
所以需要隐藏掉 一些
1.隐藏dashboard
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/profile.php'); } } add_action('admin_menu', 'remove_the_dashboard');
2.隐藏 tools theme等
//Hide non-userd admin menu bar function yg_remove_menu_page() { remove_menu_page('tools.php'); remove_menu_page('themes.php'); } add_action( 'admin_menu', 'yg_remove_menu_page' );
3.隐藏后台的wordpress信息
//Hide the wordpress info function change_footer_admin () { return 'Powerd by Gruden'; } add_filter('admin_footer_text', 'change_footer_admin', 9999); function change_footer_version() { return ' '; } add_filter( 'update_footer', 'change_footer_version', 9999);