Created
August 3, 2016 10:47
-
-
Save asharirfan/05265478e0aac8d0c096090268b1a0da to your computer and use it in GitHub Desktop.
Limit the access of a certain user role to dashboard.
This file contains hidden or 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 ( ! function_exists( 'wp_limit_dashboard_access' ) ) { | |
/** | |
* Limit the access of a certain user role to dashboard. | |
*/ | |
function wp_limit_dashboard_access() { | |
if ( current_user_can( 'user-role' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
wp_redirect( home_url() ); | |
} | |
} | |
add_action( 'init', 'wp_limit_dashboard_access' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment