Documentation

Update

Description

bool
CUser::Update(
 int id,
 array fields,
string authActions = true
)

The method modifies parameters of the user with id. Returns true on success. In case of an error the method will return false, and the LAST_ERROR property will contain the error description. When a user with such id doesn't exist, returns no error. Non-static method.

Parameters

ParameterDescriptionAvailable fr om version
id User ID.
fields Array array of values in the format array("field"=>"value" [, ...]). The field names may include all the CUser class fields as well as GROUP_ID - an array of user group ID's to which the user belongs.

To update the user avatar (field PERSONAL_PHOTO) you need to pass a full path to a newly uploaded photo on the server, not the uploaded file ID.

authActions Enables user authorization after the data is updated; true by default, which means authorization is not performed.

See Also

Examples of use

<?
$user = new CUser;
$fields = Array(
  "NAME"              => "John",
  "LAST_NAME"         => "Harrington",
  "EMAIL"             => "john@bitrix_support.com",
  "LOGIN"             => "ivan",
  "LID"               => "en",
  "ACTIVE"            => "Y",
  "GROUP_ID"          => array(1,2),
  "PASSWORD"          => "123456",
  "CONFIRM_PASSWORD"  => "123456",
  );
$user->Update($ID, $fields);
$strError .= $user->LAST_ERROR;
?>

To update a user field of "list" type (wh ere 11,12,13 - are IDs of list values.):

$user = new CUser;
$fields = Array( 
"UF_SHOP" => array(11,12,13), 
); 
$user->Update($ID, $fields);


© «Bitrix24», 2001-2024