PostNuke Help |
||
|---|---|---|
Previous |
Next |
|
get user variable
mixed pnUserGetVar(name, uid(opt));
pnUserGetVar() obtains a user-specific variable from the PostNuke system. By default it will obtain a variable for the current user; if the optional uid variable is supplied it will obtain the variable for that user instead.
The name of the user variable to obtain
The uid of the user to obtain this variable for
This function returns the requested variable if either the user is logged in to the system or an existing user's ID is passed in to the function, and the variable exists. If the variable does not exist this function will return void. This function returns void if an exception was raised.
This function raises BAD_PARAM if you pass an invalid parameter. This function raises DATABASE_ERROR if an error occurs while querying data. This function raises ID_NOT_EXIST if the user id is unknown. This function raises MODULE_FILE_NOT_EXIST if a authentication module file doesn't exist. This function raises MODULE_FUNCTION_NOT_EXIST if a authentication module function doesn't exist. This function raises MODULE_NOT_EXIST if the authentication module doesn't exist. This function raises NOT_LOGGED_IN if the user is not logged in. This function raises NO_PERMISSION if you don't have right permission to get variable value. This function raises UNKNOWN for internal problems. This function raises VARIABLE_NOT_REGISTERED if the metadata of variable you are asking for is not registered.
The user-specific variables available with this release of the API are as follows:
The user's email address
The user's real name
The name of the user's theme
The user's timezone offset, in hours from GMT-12
The user's identification number, normally only used for internal purposes
The user's login name
The user's URL
The filename of the user's avatar
Other variables will be made available in future releases of the API. You can register new user variables with the register_user_var module API function included in Modules module. See the User Variable section in the PostNuke Module Development Guide for getting an explanation on user variables.
// Show information for logged in user
if (pnUserLoggedIn()) {
$name = pnUserGetVar('name');
if (isset($name)) {
echo "Welcome to the site, $name";
}
}
// Show information for specific user
$useremail = pnUserGetVar('email', 5);
$username = pnUserGetVar('name', 5);
if (!empty($useremail) && !empty($username)) {
echo "$username has email address $useremail";
}
Previous |
Next |