Users

These are examples of queries to fetch user data and log the user in.

Fetching users permalink

A single user with his/her posts:

A list of 5 users, ordered by name:

A list of predefined users:

Filtering users by name:

Counting user results:

Paginating users:

Fetching meta values:

Fetching roles and capabilities permalink

โš ๏ธ Note: These fields are available when module "Schema for the Admin" is enabled. Read more in guide Querying 'unrestricted' fields.

Getting the roles and capabilities for the users:

Logging the user in and out permalink

Logging the user in is required to execute mutations (create a post, add a comment, etc).

This query logs the user in (execute it to log in to the demo site, using a test account with role subscriber):

To retrieve the logged-in user:

Log the user out: