[Mediawiki-l] Changing User: URL link

Alexis Moinet alexis.moinet at fpms.ac.be
Mon Sep 10 14:28:01 UTC 2007


Paul Coghlan wrote :
> Unfortunately it changes each of the personal urls to that URL not just the
> User: link.
> 
> There are two personal urls, one is the user: link the other is a Log Out
> link. With this change both become /user/YY  ?

right, I should have read (and tested) more carefully

another (tested and working on 1.10, afaik) solution is this one :

In LocalSettings.php, at the end of the file, add this :

$wgHooks['PersonalUrls'][] = 'fnPersonalUrlsHook';

function fnPersonalUrlsHook(&$personal_urls, &$wgTitle) {
	global $wgUser;

	if ($wgUser->isLoggedIn()) {
		/*in case the user is logged in*/
		$personal_urls['userpage']['href'] = "/user/" . $wgUser->getID();
		/*talk page url*/
		$personal_urls['mytalk']['href'] = "/user/" . $wgUser->getID() . "/talk";
	} else {
		/*IP-identified user have ID 0*/
		$personal_urls['anonuserpage']['href'] = "/user/0";
		/*talk page url*/
		$personal_urls['anontalk']['href'] = "/user/talk";
	}

	return $personal_urls;
}



More information about the MediaWiki-l mailing list