user.update

Description

object user.update(object/array users)

This method allows to update existing users.

This method is available to users of any type. Permissions to call the method can be revoked in user role settings. See User roles for more information.

The strength of user password is validated according the password policy rules defined by Authentication API. See Authentication API for more information.

Parameters

(object/array) User properties to be updated.

The userid property must be defined for each user, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged.

Additionally to the standard user properties, the method accepts the following parameters.

ParameterTypeDescription
passwdstringUser’s password.

Can be empty string if user belongs to or is moved only to groups that have LDAP access.
usrgrpsarrayUser groups to replace existing user groups.

The user groups must have the usrgrpid property defined.
mediasarrayUser media to replace existing media.

Return values

(object) Returns an object containing the IDs of the updated users under the userids property.

Examples

Renaming a user

Rename a user to John Doe.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.update",
  4. "params": {
  5. "userid": "1",
  6. "name": "John",
  7. "surname": "Doe"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "userids": [
  5. "1"
  6. ]
  7. },
  8. "id": 1
  9. }

Changing user role

Change a role of a user.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "user.update",
  4. "params": {
  5. "userid": "12",
  6. "roleid": "6"
  7. },
  8. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  9. "id": 1
  10. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": {
  4. "userids": [
  5. "12"
  6. ]
  7. },
  8. "id": 1
  9. }

See also

Source

CUser::update() in ui/include/classes/api/services/CUser.php.