欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal7 user_load_by_name user load by name 有大用

Fetch a user object by account name.

Parameters

$name: String with the account's user name.

Return value

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

See also

user_load_multiple()

17 calls to user_load_by_name()

File


  • modules/

    user/

    user.module, line 397

  • Enables the user registration and login system.


Code

function user_load_by_name($name) {  $users = user_load_multiple(array(
    
  ), array(    'name' => $name,
  ));  return reset($users);
}

Comments

aaronbauman’s picture

This function is a simple wrapper to DrupalEntityControllerInterface::load(), which statically caches results.

Calling this function more than once during a single pageload could return stale results.

usmanjutt84’s picture

Is this API works for only logged in user. If yes I need to load before login if exists. Any help

来自 https://api.drupal.org/api/drupal/modules!user!user.module/function/user_load_by_name/7.x

普通分类: