Manages users, along with their roles, capabilities, and meta.
Kind: global class
- User
- new User(site)
- .wpUser(commands) ⇒
Promise.<RunInContainerOutput>
- .addCap(user, cap) ⇒
Promise.<RunInContainerOutput>
- .addRole(user, role) ⇒
Promise.<RunInContainerOutput>
- .create(options) ⇒
Promise.<RunInContainerOutput>
- .delete(user, [reassign]) ⇒
Promise.<RunInContainerOutput>
- .get(user) ⇒
Promise.<UserGetObject>
- .list([filters]) ⇒
Promise.<Array.<UserGetObject>>
- .listCaps(user) ⇒
Promise.<Array.<{name: string}>>
- .removeCap(user, cap) ⇒
Promise.<RunInContainerOutput>
- .removeRole(user, cap) ⇒
Promise.<RunInContainerOutput>
- .setRole(user, role) ⇒
Promise.<RunInContainerOutput>
- .spam(user) ⇒
Promise.<RunInContainerOutput>
- .unspam(user) ⇒
Promise.<RunInContainerOutput>
- .update(options) ⇒
Promise.<RunInContainerOutput>
Constructor for the User object.
Param | Type | Description |
---|---|---|
site | Container |
the wordpress site to work on. |
user.wpUser(commands) ⇒ Promise.<RunInContainerOutput>
Run wp user command on a wp cli continer that connect to the site provied in the constructor.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
commands | Array.<string> |
commands passing to wp user. |
user.addCap(user, cap) ⇒ Promise.<RunInContainerOutput>
Adds a capability to a user.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | number | string |
User ID, user email, or user login. |
cap | string |
The capability to add. |
user.addRole(user, role) ⇒ Promise.<RunInContainerOutput>
Adds a role for a user.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | number | string |
User ID, user email, or user login. |
role | string |
Add the specified role to the user. |
user.create(options) ⇒ Promise.<RunInContainerOutput>
Creates a new user.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- Retruns newy created User id.
Param | Type | Description |
---|---|---|
options | object |
Options to create new user. |
options.userLogin | string |
The login of the user to create. |
options.userPass | string |
The user password. |
[options.role] | 'administrator' | 'editor' | 'author' | 'contributor' | 'subscriber' |
The role of the user to create. Default: default role. Possible values include ‘administrator’, ‘editor’, ‘author’, ‘contributor’, ‘subscriber’. |
[options.userRegistered] | Date |
The date the user registered. Default: current date. |
[options.displayName] | string |
The display name. |
[options.userNicename] | string |
A string that contains a URL-friendly name for the user. The default is the user’s username. |
[options.userUrl] | string |
A string containing the user’s URL for the user’s web site. |
[options.nickname] | string |
The user’s nickname, defaults to the user’s username. |
[options.firstName] | string |
The user’s first name. |
[options.lastName] | string |
The user’s last name. |
[options.description] | string |
A string containing content about the user. |
[options.userEmail] | string |
The email address of the user to create. default: ${options.userLogin}@cywp.local |
user.delete(user, [reassign]) ⇒ Promise.<RunInContainerOutput>
Deletes one or more users from the current site.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | string | number |
The user login, user email, or user ID of the user(s) to delete. |
[reassign] | number |
User ID to reassign the posts to. |
user.get(user) ⇒ Promise.<UserGetObject>
Get user data.
Kind: instance method of User
Returns: Promise.<UserGetObject>
- Current user data.
Param | Type | Description |
---|---|---|
user | string | number |
The user to get. |
user.list([filters]) ⇒ Promise.<Array.<UserGetObject>>
Return list of users in the wordpress site and there data.
Kind: instance method of User
Returns: Promise.<Array.<UserGetObject>>
- - List of users in the wordpress site.
Param | Type | Description |
---|---|---|
[filters] | UserGetObject |
Filter results based on the value of a field. |
Return the user's capabilities
Kind: instance method of User
Returns: Promise.<Array.<{name: string}>>
- List of the user capabilities.
Param | Type | Description |
---|---|---|
user | string | number |
User to check |
user.removeCap(user, cap) ⇒ Promise.<RunInContainerOutput>
Removes a user's capability.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | string | number |
User ID, user email, or user login. |
cap | string |
The capability to be removed. |
user.removeRole(user, cap) ⇒ Promise.<RunInContainerOutput>
Removes a user's role.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | string | number |
User ID, user email, or user login. |
cap | string |
A specific role to remove. |
user.setRole(user, role) ⇒ Promise.<RunInContainerOutput>
Sets the user role.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The output of the command.
Param | Type | Description |
---|---|---|
user | string |
User ID, user email, or user login. |
role | string |
Make the user have the specified role. If not passed, the default role is used. |
user.spam(user) ⇒ Promise.<RunInContainerOutput>
Marks one or more users as spam.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The command output
Param | Type | Description |
---|---|---|
user | string | number | Array.<number> | Array.<string> |
One or more id's of users to mark as spam. |
user.unspam(user) ⇒ Promise.<RunInContainerOutput>
Removes one or more users from spam.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- The command output
Param | Type | Description |
---|---|---|
user | string | number | Array.<number> | Array.<string> |
One or more IDs of users to remove from spam. |
user.update(options) ⇒ Promise.<RunInContainerOutput>
Updates an existing user.
Kind: instance method of User
Returns: Promise.<RunInContainerOutput>
- the output of the command.
Param | Type | Description |
---|---|---|
options | object |
Options to update user. |
options.user | string | number | Array.<string> | Array.<number> |
The user login, user email or user ID of the user(s) to update. |
[options.userPass] | string |
A string that contains the plain text password for the user. |
[options.userNicename] | string |
A string that contains a URL-friendly name for the user. The default is the user’s username. |
[options.userUrl] | string |
A string containing the user’s URL for the user’s web site. |
[options.userEmail] | string |
A string containing the user’s email address. |
[options.displayName] | string |
A string that will be shown on the site. Defaults to user’s username. |
[options.nickname] | string |
The user’s nickname, defaults to the user’s username. |
[options.firstName] | string |
The user’s first name. |
[options.lastName] | string |
The user’s last name. |
[options.description] | string |
A string containing content about the user. |
[options.userRegistered] | Date |
The date the user registered. |
[options.role] | 'administrator' | 'editor' | 'author' | 'contributor' | 'subscriber' |
A string used to set the user’s role. |