To expand on Countzero's answer a bit with an example:
If we have a function in a custom module that is passed the UID, for this example we will update a user from 'blocked' to 'active' using Drupal's user_load() and user_save() functions.
function MYMODULE_update_user($uid) {
// Load user object.
// To avoid confusion and to avoid clobbering the global $user object,
// assign the result of this function to a different local variable.
$account = user_load($uid);
// Change user from 'blocked' to 'active'.
user_save($account, array('status'=> 1));
}
The user_save()
documentation is as follows:
user_save($account, $edit = array(), $category = 'account')
Parameters
$account: (optional) The user object to modify or add. If you want to modify an existing user account, you will need to ensure that (a)
$account is an object, and (b) you have set $account->uid to the
numeric user ID of the user account you wish to modify. If you want to
create a new user account, you can set $account->is_new to TRUE or
omit the $account->uid field.
$edit: An array of fields and values to save. For example array('name' => 'My name'). Key / value pairs added to the
$edit['data'] will be serialized and saved in the {users.data} column.
$category: (optional) The category for storing profile information in.
Return value
A fully-loaded $user object upon successful save or FALSE if the save
failed.
To determine what part of the $edit array()
to modify, you can do something like a hook_form_alter
to dpm()
out the user object.