---
description: >-
  https://stackoverflow.com/questions/48993170/get-users-by-meta-key-and-array-of-meta-values
---

# Get users by meta\_key table wp\_usermeta(ok)

<figure><img src="https://1113999984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M84NwP_L_qEsBHOa2xo%2Fuploads%2FJakCy1Fg6TkbdwRUH13g%2Fimage.png?alt=media&#x26;token=f725bd1d-e032-46fe-9aac-a699e666b31f" alt=""><figcaption></figcaption></figure>

```php
$user_id = $current_user->ID;
    $usermeta = get_user_meta($user_id, '_sfwd-quizzes', true);
    $user_args = array(
      'meta_query' => array(
        array(
          'key'  => '_sfwd-quizzes'
        )
      ),
    );
$usersID = get_users($user_args);
$gusersID = [];
foreach( $usersID as $userID) :
   $gusersID[] = $userID->ID;
endforeach;
echo '<pre>';
   var_export($gusersID);
echo '</pre>';
```

<figure><img src="https://1113999984-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M84NwP_L_qEsBHOa2xo%2Fuploads%2FY7PxDrVPAOU3FUqSfrKV%2Fimage.png?alt=media&#x26;token=3812c479-0c1c-4cdb-baea-b1f4efeccedf" alt=""><figcaption></figcaption></figure>
