Skip to content

Instantly share code, notes, and snippets.

@irkanu
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save irkanu/17f5acd288cea517b448 to your computer and use it in GitHub Desktop.
Save irkanu/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