User

userRegistry. User

Class representing a user. Is made similar to mw.user so that it is possible to pass it to mw.msg() and have {{gender:}} replaced.

To create an instance, use module:userRegistry.get (the constructor is only exported for means of code completion).

Constructor

new User(name, options)

Source:

Create a user object.

Parameters:
Name Type Description
name string
options object

Methods

getGender() → {'male'|'female'|'unknown'}

Source:

User's gender (must be obtained using module:utilsApi.loadUserGenders).

Returns:
Type
'male' | 'female' | 'unknown'

getGlobalId() → {number}

Source:

Get the user's global ID according to the database if it was set before.

Returns:
Type
number

getName() → {string}

Source:

Get the user name.

Returns:
Type
string

getNamespaceAlias() → {string}

Source:

Get the preferred namespace alias, based on:

  1. the genderNeutralUserNamespaceAlias CD config value (first choice);
  2. the userNamespacesByGender CD config value, if the gender is known (second choice);
  3. the wgFormattedNamespaces MediaWiki config value (third choice).
Returns:
Type
string

(nullable) getRights()

Source:

Get the user's rights (must be obtained using module:utilsApi.getUserInfo).

isMuted() → {boolean}

Source:

Check if the user is muted.

Returns:
Type
boolean

isRegistered()

Source:

Is the user registered (not an IP user). Temporary accounts are considered registered users.

setGender(value)

Source:

Set a gender for the user.

Parameters:
Name Type Description
value 'male' | 'female' | 'unknown'

setGlobalId(value)

Source:

Set the user's global ID according to the database.

Parameters:
Name Type Description
value number

setMuted(value)

Source:

Set if the user is muted.

Parameters:
Name Type Description
value boolean

setRights(rights)

Source:

Set the user's rights.

Parameters:
Name Type Description
rights Array.<string>