wordpress 移除 后台某些选项卡 及 后台adminbar的 dashboard选项
有时候为客户做后台不需要让非管理员用户看到 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);
相关推荐
技术积累LZ 2020-07-28
liaochaowu 2020-06-12
matthewhan 2020-06-08
wishli 2020-05-28
JustHaveTry 2020-05-11
guan000 2020-05-09
Leonwey 2020-05-07
chognzhihongseu 2020-05-01
guan000 2020-02-17
hubanbei00的家园 2020-02-10
kjh00abc 2020-01-29
CurrentJ 2020-01-23
topswim 2020-01-11
kjh00abc 2020-01-08
CurrentJ 2020-01-09
CurrentJ 2020-01-07
yibuchen 2019-11-21
小火车 2019-11-10