Created
July 5, 2017 08:44
-
-
Save NichlasB/ef17e375c708145f17896a425f62811c to your computer and use it in GitHub Desktop.
Block Admin Access for Specified User Roles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly | |
/** | |
* block-role-admin-access.php | |
*/ | |
function cf_block_role_admin_access() { | |
$redirect = home_url( '/' ); | |
if ( current_user_can( 'student' ) && ! current_user_can( 'administrator' ) ) | |
exit( wp_redirect( $redirect ) ); | |
} | |
add_action( 'admin_init', 'cf_block_role_admin_access', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment