Paste this function into your themes "functions.php" to redirect every specific user role from the admin back to your homepage:
add_action('admin_init', function() {
$wp_user = wp_get_current_user();
if(isset($wp_user->caps['subscriber']) && $wp_user->caps['subscriber']){
wp_redirect(get_site_url());
exit;
}
});
Here, "subscriber" is user role slug change this as your user role.
it can be author, contributor, editor,
add_action('admin_init', function() {
$wp_user = wp_get_current_user();
if(isset($wp_user->caps['subscriber']) && $wp_user->caps['subscriber']){
wp_redirect(get_site_url());
exit;
}
});
Here, "subscriber" is user role slug change this as your user role.
it can be author, contributor, editor,
0 comments:
Post a Comment