UserRepository

WP_User_Query Wordpress wrapper to query objects

Methods

count($criteria)

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, $orderBy, $limit, $offset)

Finds entities by a set of criteria.

findOneBy($criteria, $orderBy)

Finds a single entity by a set of criteria.

findQueried()

Finds a single entity related to the main query

Example

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);
}

Last updated