wc_user_has_role()
Checks if a user has a role.
No Hooks.
Return
true|false
.
Usage
wc_user_has_role( $user, $role );
- $user(int|\WP_User) (required)
- The user.
- $role(string) (required)
- The role.
wc_user_has_role() wc user has role code WC 9.4.2
function wc_user_has_role( $user, $role ) { if ( ! is_object( $user ) ) { $user = get_userdata( $user ); } if ( ! $user || ! $user->exists() ) { return false; } return in_array( $role, $user->roles, true ); }