how to get logged in user name in mediaWiki before the page is rendered?
hello i am hacking ApprovedRevs mediaWiki extension I am using mediaWiki 1.16
basically i need to know the name of current logged in us开发者_Go百科er in mediaWiki in a function which is executed when an UnknownAction hook is fired,
I know i can access the logged in user name $wgUser->mName; $wgUser being a global variable but what i get is an empty string
I did print_r in skin file (vector.php) and it contained all the info there but when i did the same in the function i am working on i got this:
StubUser Object
(
[mGlobal] => wgUser
[mClass] =>
[mParams] => Array
(
)
)
i.e it was empty so can anyone tell me what should i do?
You should use the object's getName
method (like $wgUser->getName()
) instead of accessing the property directly.
This is because the object is initially a stub object. This means that the data aren't loaded until the first method call. You can see the reference documentation on StubObject
.
精彩评论