Manual:User.php

From MediaWiki.org
Jump to: navigation, search

Other languages:
Deutsch • ‎English • ‎español • ‎français • ‎italiano • ‎日本語 • ‎polski • ‎português • ‎português do Brasil

Description[edit]

User.php implements the User class, which encapsulates all of the user-specific settings (user_id, name, rights, password, email address, options, last login time). Client classes use the getXXX() functions to access these fields. These functions do all the work of determining whether the user is logged in, whether the requested option can be satisfied from cookies or whether a database query is needed. Most of the settings needed for rendering normal pages are set in the cookie to minimize use of the database.

createAndPromote.phpManual:createAndPromote.php uses User::newFromName(), User::addToDatabase(), and User::saveSettings().

Static factory methods[edit]

  • static newFromName ($name, $validate= 'valid')
  • static newFromId ($id)
  • static newFromConfirmationCode ($code)
  • static newFromSession (WebRequest $request=null)
  • static newFromRow ($row, $data=null)

Other methods[edit]

There are a whole host of other ones. See https://doc.wikimedia.org/mediawiki-core/master/php/classUser.html for the full list.

  • getId(): Get the user's ID. Returns 0 if the user is anonymous or nonexistent.
  • getName(): Get the user name, or the IP of an anonymous user.
  • getEmail(): Get the user's e-mail address.
  • getGroups(): Get the list of explicit group memberships this user has. (The implicit * and user groups are not included.)
  • getRights(): Get the permissions this user has.

See also[edit]