PostNuke Help |
||
|---|---|---|
Previous |
Next |
|
validate user variable
bool pnUserValidateVar()(name, value);
pnUserValidateVar() validates a user-specific variable on the PostNuke system.
The name of a user variable to validate
The value to be validate against the named user variable
This function returns true if the validation is successful, false if the validation fails. 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 UNKNOWN for internal problems. This function raises VARIABLE_NOT_REGISTERED if the metadata of variable you are asking for is not registered.
See the User Variable section in the PostNuke Module Development Guide for getting an explanation on user variables.
// Validate the user's email address
if (!pnUserValidateVar('email', $email)) {
module_user_askdata(array('errmsg' => 'Invalid email'));
}
// Validate the user's timezone_offset address
if (!pnUserValidateVar('timezone_offset', $timezone_offset)) {
module_user_askdata(array('errmsg' => 'Invalid timezone offset'));
}
pnUserSetVar('email', $email);
pnUserSetVar('timezone_offset', $timezone_offset);
Previous |
Next |