在您的functions.php
文件或插件中-
function wpse_253580_prevent_author_access(){
if( current_user_can( \'author\' ) && is_admin() ) {
// do something here. maybe redirect to homepage
wp_safe_redirect( get_bloginfo( \'url\' ) );
}
}
add_action( \'admin_init\', \'wpse_253580_prevent_author_access\' );
这将检查当前用户是否是
author 他正试图进入
wp-admin 地区如果为true,则将其重定向到
homepage.