Skip to content

Instantly share code, notes, and snippets.

@LateButEarly
Last active August 29, 2015 14:20
Show Gist options
  • Save LateButEarly/17f5acd288cea517b448 to your computer and use it in GitHub Desktop.
Save LateButEarly/17f5acd288cea517b448 to your computer and use it in GitHub Desktop.
WooCommerce Role Redirect
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