Redirect Subscribers Away from wp-admin
Redirects logged-in users who lack editing capabilities to the homepage when they try to access wp-admin.
PHPby SnipCraft
php
<?php
add_action( 'admin_init', 'scseed_redirect_non_editors_from_admin' );
function scseed_redirect_non_editors_from_admin() {
if (
! current_user_can( 'edit_posts' ) &&
! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) &&
! ( defined( 'DOING_CRON' ) && DOING_CRON )
) {
wp_redirect( home_url( '/' ) );
exit;
}
}#admin#roles#security#users