JavaScript API Class: User
The User class represents a registered or anonymous user. It can be accessed via the "user" implicit object. Future API versions will provide more robust user management.
Properties
| Name | Type | Access |
Description |
| alert |
Number |
read/write |
The number of hours between email change alerts for this user. Returns 0 if this user has opted-out of email alerts. |
| alertMinor | Boolean |
read/write |
True if this user has opted in to receive alerts for minor edits. |
| email |
String |
read/write |
Email address for this user. |
| hash | String |
read |
A hash value used for security purposes. Only set for the current logged-in user. |
| isAdmin |
Boolean | read |
True if this user is an Administrator. |
| isLoggedIn |
Boolean |
read | False if this is an anonymous user. |
| isRegistered |
Boolean |
read |
True if this user is in the defaut Registered group. |
| name |
String |
read/write |
This user's login name. Note that user names cannot be changed. The name can only be set for a new user that does not yet have a name. |
| password |
String |
write |
Sets the user's password. Note that an existing password cannot be retrieved. Use the passwordMatches() function to test for password validity. |
| timeZone |
String |
read/write |
The time zone this user selected in user preferences. |
| userType | String |
read/write |
Set's the user type, which can be Public, Registered, Administrator or Locked. Note that while a public user will return Public, you cannot set the type of an existing user as Public as Public users cannot be saved. User type must be set to something other than Public before save() is called on a new user. |
Functions
| Name | Return Type |
Description |
| lock() |
None |
Sets this user's status to Locked. |
| save() | None |
Saves this user. Note that userType cannot be Public when save() is called. |
| passwordMatches(String) |
Boolean | Returns true if the String matches the stored password for this user. |
| destroy() |
None |
Permanently deletes this user. |
Example
// a function that returns a welcome message for the given user
function welcomeText(user) {
if (!user.isLoggedIn) return 'Welcome, Anonymous!';
else return 'Welcome, ' + user.name + '!';
}
Return to Java Script API