WP_User wrapper class.
This class wrap a WP_User object and give them some helpers and some features like get_avatar_url, accessor like get_login, get_page_url, etc...
$user = new \WPS\User($wp_user);
$avatarUrl = $user->avatar_url;Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Construct the object using the passed wp_user
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $wp_user | { WP_User } | The wordpress user object to encapsulate | required |
$wpsUser = new \WPS\User($wp_user);Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
The user id
Type : { Integer }
Public
Default : null
The user login
Type : { String }
Public
Default : null
The user password
Type : { String }
Public
Default : null
The user nicename
Type : { String }
Public
Default : null
The user email
Type : { String }
Public
Default : null
The user firstname
Type : { String }
Public
Default : null
The user lastname
Type : { String }
Public
Default : null
The user website url
Type : { String }
Public
Default : null
The user registration datetime
Type : { String }
Public
Default : null
The user activation key
Type : { String }
Public
Default : null
The user status
Type : { String }
Public
Default : null
The user display name
Type : { String }
Public
Default : null
The user capabilities
Type : { Array }
Public
Default : []
All the user capabilities
Type : { Array }
Public
Default : []
The user roles
Type : { Array }
Public
Default : []
Properties accessor
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Get the page url of the author
Return { String } The page url of the author
$pageUrl = $user->page_url;Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Get the avatar url for this user
Return { String } The avatar url
$avatarUrl = $user->avatar_url;Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Get the avatar url for this user using some arguments like size
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $size | { Integer } | The size wanted for the avatar | optional | 96 |
| $default | { String } | The default avatar to return if none exists | optional | "gravatar_default" |
Return { String } The avatar url
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Determine whether the user exists in the database. It actually tests !empty(ID), which will normally indicate that the user record was in the database at some stage. It does not access the database.
Return { Boolean } true if user exists, false otherwise.
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Retrieve the value of a property or meta key from the users and usermeta tables.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $key | { String } | property | required |
Return { Mixed } String of the property filtered if single value, or array if value is stored as a serialized array
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Determine whether a property or meta key is set from the users and usermeta tables.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $key | { String } | property | required |
Return { Boolean } true if user has property, false otherwise
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Add role to user. Updates the user's meta data option with capabilities and roles.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $role | { String } | Role name | required |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Remove role from user.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $role | { String } | Role name | required |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Set the role of the user. This will remove the previous roles of the user and assign the user the new one. You can set the role to an empty string and it will remove all of the roles from the user.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $role | { String } | Role name | required |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Add capability and grant or deny access to capability.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $cap | { String } | Capability name | required | |
| $grant | { Boolean } | whether to grant capability to user. Default to true. | required |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Remove capability from user
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $cap | { String } | Capability name | required |
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Remove all of the capabilities of the user.
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public
Whether user has capability or role name.
| Name | Type | Description | Status | Default |
|---|---|---|---|---|
| $cap | { String } | capability or role name to search | required |
Return { Boolean } true if user has capability, false if they do not have the capability
Author : Olivier Bossel olivier.bossel@gmail.com https://olivierbossel.com
Public