# UserRepository

{% hint style="info" %}
[WP\_User\_Query](https://developer.wordpress.org/reference/classes/wp_user_query/) Wordpress wrapper to query objects
{% endhint %}

## Methods

#### count([$criteria](https://developer.wordpress.org/reference/classes/wp_user_query/#parameters))

Counts entities by a set of criteria.

#### find($id)

Finds an entity by its primary key / identifier.

#### findAll($orderBy)

Finds all public entities in the repository.

#### findBy([$criteria](https://developer.wordpress.org/reference/classes/wp_user_query/#parameters), $orderBy, $limit, $offset)

Finds entities by a set of criteria.

#### findOneBy([$criteria](https://developer.wordpress.org/reference/classes/wp_user_query/#parameters), $orderBy)

Finds a single entity by a set of criteria.

#### findQueried()

Finds a single entity related to the main query

## Example

```php
public function pageAction(Post $post, UserRepository $userRepository)
{
  $context = [
    'post'=>$post,
    'subscribers'=>$userRepository->findBy(['role' => 'subscriber'],['email'=>'ASC'], 3)
  ];
  
  return $this->render('single.html.twig', $context);
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://metabolism.gitbook.io/symfony-wordpress-bundle/reference/repository/userrepository.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
