I'm trying to extend the user class of MediaWiki by adding some methods like $user->getNameOfPet()
. Eg the extension Article_Class_Extended
extends the default article class using a hook:
$wgExtensionFunctions[] = "wfArticleExSetup";
function wfArticleExSetup()
{
global $wgHooks;
$wgHooks['ArticleFromTitle'][] = 'wfArticleExInit';
}
function wfArticleExInit( &$title, &$article )
{
// What really counts is what is returned in $article.
$GLOBALS['wgArticle'] = new ArticleExClass( $title, $article, true );
return true;
}
Is there a way for extending the user class in a similar way? I'm using MediaWiki 1.16.5.
I think from your settings file you could call
RequestContext::getMain()->setUser(new User());
I've used this to force an 'empty' (not logged in) user. If this call lets you set a user object, you should be able to feed it a User descendant as well. This line is similar to the line in Setup.php that sets the $wgUser global.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.