WPDKUser::hasRoles PHP Метод

hasRoles() публичный Метод

Return TRUE if the current user has one o more roles.
public hasRoles ( string | array $roles ) : boolean
$roles string | array Single string or array list of roles.
Результат boolean TRUE if user has the role, else FALSE.
    public function hasRoles($roles)
    {
        global $wp_roles;
        if (!isset($wp_roles)) {
            $wp_roles = new WP_Roles();
        }
        $current_roles = $this->roles;
        if (is_array($roles)) {
            foreach ($roles as $role) {
                if (in_array($role, $current_roles)) {
                    return true;
                }
            }
            return false;
        } else {
            return in_array($roles, $current_roles);
        }
    }