Contents
On this page

Search Users for Access Rules - Plugixa Exam

GET /plugixa-exam/v1/cohorts/users

Find users by name, username or email address, to build a user access rule.

Not reachable with an API token: since 1.4.1 a token request to this route answers 403 plugixa_exam_token_route. Call it as a signed-in WordPress user (from a script, with an Application Password) who holds the exams:edit permission. Needs Plugixa Exam Pro with the Cohorts app on in Plugixa Exam -> App Manager; with it off, this route answers 404.

Note. The search matches e-mail addresses as well as names, and the answer gives each match’s user id and display name, never the address itself. Only users who may edit exams can call it. When this route refuses, the code is WordPress’s own rest_forbidden.

Request

GET https://your-site.example/wp-json/plugixa-exam/v1/cohorts/users?search=jordan

Query parameters

Name Type Default Description
search string Text found anywhere in the username, the user’s URL name, the email address or the display name. Empty answers an empty list.

This endpoint is not paged and takes no other list parameters.

Responses

200 OK. data is the list of matching users.

Sorted by display name, at most 20.

{
  "success": true,
  "data": [
    { "id": 58, "name": "Jordan Lee" },
    { "id": 73, "name": "Jordan Smith" }
  ]
}
Field Type Meaning
data[].id integer The WordPress user id, for subject_id in a rule
data[].name string The user’s display name

Errors

Status Code When
401 / 403 rest_forbidden Not signed in (401), or the user may not edit exams (403).

Plus the errors every endpoint can return.

Examples

curl -s "https://your-site.example/wp-json/plugixa-exam/v1/cohorts/users?search=jordan" \
  -u "$WP_USER:$WP_APP_PASSWORD"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-exam/v1/cohorts/users?search=jordan');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Basic ' . base64_encode(getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD')),
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-exam/v1/cohorts/users?search=jordan', {
  headers: {
    'Authorization': 'Basic ' + btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`),
  },
});
const { data } = await response.json();

Quick Links

Share