Add a UserDisplayName hook to allow extensions to give custom display names for users.
Add a $wgRealNameInInterface to use the real name of a user as the display name.
To start of the first use of the display name functionality tweak SkinTemplate to declare the userdisplayname and use it inside of personal_urls.
* The default user signature now contains a talk link in addition to the user link.
* (bug 25306) Add link of old page title to MediaWiki:Delete_and_move_reason
* Added hook BitmapHandlerCheckImageArea
+* (experimental) $wgRealNameInInterface can be enabled to display a user's
+ real name in some parts of the interface instead of a username.
=== Bug fixes in 1.19 ===
* $wgUploadNavigationUrl should be used for file redlinks if
hashing method
&$hash: If the hook returns false, this String will be used as the hash
+'UserDisplayName': Called in User::getDisplayName()
+$user: The user object to fetch the display name for
+&$displayName: The display name. Will be null. Set to a name to override default name.
+
'UserEffectiveGroups': Called in User::getEffectiveGroups()
$user: User to get groups for
&$groups: Current effective groups
*/
$wgShowIPinHeader = true;
+/**
+ * Use a user's real name inside the user interface for display instead of the username
+ * (experimental)
+ */
+$wgRealNameInInterface = true;
+
/**
* Site notice shown at the top of each page
*
$this->thisquery = wfArrayToCGI( $query );
$this->loggedin = $user->isLoggedIn();
$this->username = $user->getName();
+ $this->userdisplayname = $user->getDisplayName();
if ( $user->isLoggedIn() || $this->showIPinHeader() ) {
$this->userpageUrlDetails = self::makeUrlDetails( $this->userpage );
$tpl->set( 'capitalizeallnouns', $this->getLang()->capitalizeAllNouns() ? ' capitalize-all-nouns' : '' );
$tpl->set( 'showjumplinks', $user->getOption( 'showjumplinks' ) );
$tpl->set( 'username', $user->isAnon() ? null : $this->username );
+ $tpl->set( 'userdisplayname', $user->isAnon() ? null : $this->userdisplayname );
$tpl->setRef( 'userpage', $this->userpage );
$tpl->setRef( 'userpageurl', $this->userpageUrlDetails['href'] );
$tpl->set( 'userlang', $userlang );
$returnto = wfArrayToCGI( $a );
if( $this->loggedin ) {
$personal_urls['userpage'] = array(
- 'text' => $this->username,
+ 'text' => $this->userdisplayname,
'href' => &$this->userpageUrlDetails['href'],
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
'active' => ( $this->userpageUrlDetails['href'] == $pageurl )
if( $this->showIPinHeader() ) {
$href = &$this->userpageUrlDetails['href'];
$personal_urls['anonuserpage'] = array(
- 'text' => $this->username,
+ 'text' => $this->userdisplayname,
'href' => $href,
'class' => $this->userpageUrlDetails['exists'] ? false : 'new',
'active' => ( $pageurl == $href )
*/
var $mNewtalk, $mDatePreference, $mBlockedby, $mHash, $mRights,
$mBlockreason, $mEffectiveGroups, $mImplicitGroups, $mFormerGroups, $mBlockedGlobally,
- $mLocked, $mHideName, $mOptions;
+ $mLocked, $mHideName, $mOptions, $mDisplayName;
/**
* @var WebRequest
$this->mEffectiveGroups = null;
$this->mImplicitGroups = null;
$this->mOptions = null;
+ $this->mDisplayName = null;
if ( $reloadFrom ) {
$this->mLoadedItems = array();
$this->mRealName = $str;
}
+ /**
+ * Return the name of this user we should used to display in the user interface
+ * @return String The user's display name
+ */
+ public function getDisplayName() {
+ global $wgRealNameInInterface;
+ if ( is_null( $this->mDisplayName ) ) {
+ $displayName = null;
+
+ // Allow hooks to set a display name
+ wfRunHooks( 'UserDisplayName', array( $this, &$displayName ) );
+
+ if ( is_null( $displayName ) && $wgRealNameInInterface && $this->getRealName() ) {
+ // If $wgRealNameInInterface is true use the real name as the display name if it's set
+ $displayName = $this->getRealName();
+ }
+
+ if ( is_null( $displayName ) ) {
+ $displayName = $this->getName();
+ }
+
+ $this->mDisplayName = $displayName;
+ }
+ return $this->mDisplayName;
+ }
+
/**
* Get the user's current setting for a given option.
*