Last active
August 29, 2015 14:20
-
-
Save LateButEarly/17f5acd288cea517b448 to your computer and use it in GitHub Desktop.
WooCommerce Role Redirect
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
add_filter( 'woocommerce_prevent_admin_access', 'sfwd_check_admin_access' ); | |
function sfwd_check_admin_access( $redirect_to ) { | |
$user = wp_get_current_user(); | |
$allowed_roles = array ( 'administrator', 'group_leader' ); | |
if( is_array( $user->roles ) && in_array( $allowed_roles[0] , $user->roles ) || in_array( $allowed_roles[1] , $user->roles ) ) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment