Fetch a user object.
Parameters
$user_info:
Information about the user to load, consisting of one of the following:
- An associative array whose keys are fields in the {users} table (such as
uid, name, pass, mail, status) and whose values are the field's value.
- A numeric user ID.
Return value
A fully-loaded $user object upon successful user load or FALSE if user
cannot be loaded.
- comment_form_add_preview in modules/comment/comment.module
- Form builder; Generate and validate a comment preview form.
- comment_validate in modules/comment/comment.module
- Validate comment data.
- install_configure_form_submit in ./install.php
- Form API submit for the site configuration form.
- node_preview in modules/node/node.pages.inc
- Generate a node preview.
- node_submit in modules/node/node.module
- Prepares a node for saving by populating teaser, author, and creation date.
- node_validate in modules/node/node.module
- Perform validation checks on the given node.
- profile_block in modules/profile/profile.module
- Implementation of hook_block().
- profile_browse in modules/profile/profile.pages.inc
- Menu callback; display a list of user information.
- statistics_user_tracker in modules/statistics/statistics.pages.inc
- system_send_email_action in modules/system/system.module
- Implementation of a configurable Drupal action. Sends an email.
- user_authenticate in modules/user/user.module
- Try to log in the user locally.
- user_category_load in modules/user/user.module
- Return a user object after checking if any profile category in the path exists.
- user_delete in modules/user/user.module
- Delete a user.
- user_external_load in modules/user/user.module
- user_external_login_register in modules/user/user.module
- Helper function for authentication modules. Either login in or registers
the current user, based on username. Either way, the global $user object is
populated based on $name.
- user_load_self in modules/user/user.module
- user_multiple_role_edit in modules/user/user.module
- Callback function for admin mass adding/deleting a user role.
- user_pass_reset in modules/user/user.pages.inc
- Menu callback; process one time login link and redirects to the user page on success.
- user_pass_validate in modules/user/user.pages.inc
- user_save in modules/user/user.module
- Save changes to a user account or add a new user.
- user_uid_optional_load in modules/user/user.module
- Load either a specified or the current user account.
- user_user_operations_block in modules/user/user.module
- Callback function for admin mass blocking users.
- user_user_operations_unblock in modules/user/user.module
- Callback function for admin mass unblocking users.
- _comment_form_submit in modules/comment/comment.module
- Prepare a comment for submission.
- _trigger_normalize_comment_context in modules/trigger/trigger.module
- When an action is called in a context that does not match its type,
the object that the action expects must be retrieved. For example, when
an action that works on nodes is called during the comment hook, the
node object is not available since the…
- _trigger_normalize_node_context in modules/trigger/trigger.module
- When an action is called in a context that does not match its type,
the object that the action expects must be retrieved. For example, when
an action that works on users is called during the node hook, the
user object is not available since the node…
- _update_cron_notify in modules/update/update.fetch.inc
- Perform any notifications that should be done once cron fetches new data.
- _user_edit_submit in modules/user/user.module
File
- modules/user/user.module, line 153
- Enables the user registration and login system.
Code
<?php
function user_load($user_info = array()) {
$query = array();
$params = array();
if (is_numeric($user_info)) {
$user_info = array('uid' => $user_info);
}
elseif (!is_array($user_info)) {
return FALSE;
}
foreach ($user_info as $key => $value) {
if ($key == 'uid' || $key == 'status') {
$query[] = "$key = %d";
$params[] = $value;
}
else if ($key == 'pass') {
$query[] = "pass = '%s'";
$params[] = md5($value);
}
else {
$query[] = "LOWER($key) = LOWER('%s')";
$params[] = $value;
}
}
$result = db_query('SELECT * FROM {users} u WHERE ' . implode(' AND ', $query), $params);
if ($user = db_fetch_object($result)) {
$user = drupal_unpack($user);
$user->roles = array();
if ($user->uid) {
$user->roles[DRUPAL_AUTHENTICATED_RID] = 'authenticated user';
}
else {
$user->roles[DRUPAL_ANONYMOUS_RID] = 'anonymous user';
}
$result = db_query('SELECT r.rid, r.name FROM {role} r INNER JOIN {users_roles} ur ON ur.rid = r.rid WHERE ur.uid = %d', $user->uid);
while ($role = db_fetch_object($result)) {
$user->roles[$role->rid] = $role->name;
}
user_module_invoke('load', $user_info, $user);
}
else {
$user = FALSE;
}
return $user;
}
?>
Login or
register to post comments
Comments
extended profiles
If using the default D6 profile module, you'll have to see this documentation http://drupal.org/node/873990 for profile_* values.