function user_uid_optional_load

user_uid_optional_load($uid = NULL)

Load either a specified or the current user account.

@todo rethink the naming of this in Drupal 8.

Parameters

$uid: An optional user ID of the user to load. If not provided, the current user's ID will be used.

Return value

A fully-loaded $user object upon successful user load, FALSE if user cannot be loaded.

See also

user_load()

File

modules/user/user.module, line 1977
Enables the user registration and login system.

Code

function user_uid_optional_load($uid = NULL) {
  if (!isset($uid)) {
    $uid = $GLOBALS['user']->uid;
  }
  return user_load($uid);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_uid_optional_load/7.x