创建functionality plugin 如果要完全阻止对管理面板的访问,请使用此选项:
/**
* Hide the admin bar in the front end
*/
add_filter(\'show_admin_bar\', \'__return_false\');
/**
* Redirects Authors and Subscribers to the site front page using: get_home_url()
*/
add_action(\'admin_init\',\'block_users_wpse_53675\');
function block_users_wpse_53675()
{
if( !current_user_can( \'delete_pages\' ) ) // blocks authors, contributors and subscribers
{
wp_redirect( get_home_url(), 301 );
exit;
}
}
如果您希望用户只能访问其个人资料页面,请使用另一个:
/**
* Redirect Authors and Subscribers to the site front page
* Except if viewing the Profile page
*/
add_action(\'admin_init\',\'block_users_wpse_53675\');
function block_users_wpse_53675()
{
global $pagenow;
if( \'profile.php\' == $pagenow )
return;
if( !current_user_can(\'delete_pages\') )
{
wp_redirect( get_home_url(), 301 );
exit;
}
}
/**
* Hide all menus from the Admin panel
* Except the profile item
*/
add_action(\'admin_menu\', \'remove_admin_menus_wpse_53675\', 999);
function remove_admin_menus_wpse_53675()
{
if( !current_user_can(\'delete_pages\') )
{
remove_menu_page(\'index.php\');
remove_menu_page(\'edit.php\');
remove_menu_page(\'upload.php\');
remove_menu_page(\'link-manager.php\');
remove_menu_page(\'edit.php?post_type=page\');
remove_menu_page(\'edit-comments.php\');
remove_menu_page(\'tools.php\');
}
}
操纵角色和功能的感兴趣插件
MembersUser Role EditorRole ScoperS2Member