function node_import_userreference in Node import 5
Helper function to get a user from a string. This function will return the uid of the user found or NULL if no user matching the string was found.
If the string provided is an integer, then this function will assume that the user is identified by uid.
Otherwise, the function will lookup a user with a name matching the string.
Parameters
$name: String. Name or uid of a user.
Return value
Uid of the user found, or NULL.
3 calls to node_import_userreference()
- content_node_import_prepare in supported/
cck/ content.inc - Implementation of hook_node_import_prepare().
- node_node_import_prepare in supported/
node.inc - Implementation of hook_node_import_prepare().
- _node_import_get_nodes in ./
node_import.module - Import and create nodes.
File
- ./
node_import.api.inc, line 145
Code
function node_import_userreference($name) {
static $uids = array();
$name = trim($name);
if (!isset($uids[$name])) {
$uids[$name] = NULL;
if (strlen($name) > 0 && (is_numeric($name) && intval($name) > 0 && ($user = user_load(array(
'uid' => intval($name),
)))) || ($user = user_load(array(
'name' => $name,
))) || ($user = user_load(array(
'mail' => $name,
)))) {
$uids[$name] = $user->uid;
}
}
return $uids[$name];
}