PostNuke Help

Previous
pnUserGetTheme

Home
up

Next
pnUserGetVars


pnUserGetVar

get user variable

Synopsis

mixed pnUserGetVar(name, uid(opt));

Description

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.

Parameters

name

The name of the user variable to obtain

uid

The uid of the user to obtain this variable for

Return Values

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.

Exceptions

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.

Notes

The user-specific variables available with this release of the API are as follows:

email

The user's email address

name

The user's real name

theme

The name of the user's theme

timezone_offset

The user's timezone offset, in hours from GMT-12

uid

The user's identification number, normally only used for internal purposes

uname

The user's login name

url

The user's URL

user_avatar

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.

Examples

// 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";
}
       

See Also

pnUserSetVar()


Previous
pnUserGetTheme

Home
up

Next
pnUserGetVars