Skip to content

Commit 37d73fc

Browse files
committed
docs: add section "Finding a User"
1 parent 019fc97 commit 37d73fc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

docs/user_management/managing_users.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ Since Shield uses a more complex user setup than many other systems, separating
44

55
## Managing Users by Code
66

7+
### Finding a User
8+
9+
You can find an existing user from the User Provider. It returns a `User`
10+
[entity](https://codeigniter.com/user_guide/models/entities.html).
11+
12+
```php
13+
// Get the User Provider (UserModel by default)
14+
$users = auth()->getProvider();
15+
16+
// Find by the user_id
17+
$user = $users->findById(123);
18+
// Find by the user email
19+
$user = $users->findByCredentials(['email' => '[email protected]']);
20+
```
21+
722
### Creating Users
823

924
By default, the only values stored in the users table is the username.

0 commit comments

Comments
 (0)