User Repository

To work with the User Repository, use the following Facade:

use Statamic\Facades\User;


Methods Description
all() Get all Users
current() Get current User
find($id) Get User by id
findByEmail($email) Get User by email
findByOAuthID($provider, $id) Get User by an ID from an OAuth provider
query() Query Builder
make() Makes a new User instance


Get a user by ID

->where('id', 'abc123')
// Or with the shorthand method

Get a user by email

->where('email', '[email protected]')
// Or with the shorthand method
User::findByEmail('[email protected]');

Get a user by OAuth ID

User::findByOAuthId('github', '123');

Get all super users

User::query()->where('super', true)->get();

Get the currently logged in user



Start by making an instance of a user with the make method.
You need at least an email before you can save a user.

$user = User::make()->email('[email protected]');

You may call additional methods on the user to customize it further.

->password('plaintext') // it will be hashed for you
->data(['foo' => 'bar']) // an array of data (front-matter)
->preferences($prefs) // array of preferences
->roles($roles) // array of roles
->groups($groups); // array of groups

Finally, save it.

HR: Section
Learn More!

There is more to learn more in these related articles:


HR: Section
Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →