'UserLoginComplete': after a user has logged in
$user: the user object that was created on login
-$inject_html: Any HTML to inject after the "logged in" message. As of 1.14,
- this only applies to new account creations, since simple logins are HTTP re-
- directs.
+$inject_html: Any HTML to inject after the "logged in" message.
'UserLoginForm': change to manipulate the login form
$template: SimpleTemplate instance for the form
function successfulLogin() {
global $wgUser, $wgOut;
- # Run any hooks; ignore injected HTML since we just redirect
+ # Run any hooks; display injected HTML if any, else redirect
$injected_html = '';
wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
- $titleObj = Title::newFromText( $this->mReturnTo );
- if ( !$titleObj instanceof Title ) {
- $titleObj = Title::newMainPage();
- }
+ if( $injected_html !== '' ) {
+ $this->displaySuccessfulLogin( 'loginsuccess', $injected_html );
+ } else {
+ $titleObj = Title::newFromText( $this->mReturnTo );
+ if ( !$titleObj instanceof Title ) {
+ $titleObj = Title::newMainPage();
+ }
- $wgOut->redirect( $titleObj->getFullURL() );
+ $wgOut->redirect( $titleObj->getFullURL() );
+ }
}
/**
$injected_html = '';
wfRunHooks('UserLoginComplete', array(&$wgUser, &$injected_html));
+ $this->displaySuccessfulLogin( 'welcomecreation', $injected_html );
+ }
+
+ /**
+ * Display a "login successful" page.
+ */
+ private function displaySuccessfulLogin( $msgname, $injected_html ) {
+ global $wgOut;
+
$wgOut->setPageTitle( wfMsg( 'loginsuccesstitle' ) );
$wgOut->setRobotPolicy( 'noindex,nofollow' );
$wgOut->setArticleRelated( false );
- $wgOut->addWikiMsg( 'welcomecreation', $wgUser->getName() );
+ $wgOut->addWikiMsg( $msgname, $wgUser->getName() );
$wgOut->addHtml( $injected_html );
if ( !empty( $this->mReturnTo ) ) {
Please enable them and try again.',
'noname' => 'You have not specified a valid user name.',
'loginsuccesstitle' => 'Login successful',
+'loginsuccess' => "'''You are now logged in to {{SITENAME}} as \"\$1\".'''",
'nosuchuser' => 'There is no user by the name "$1".
Check your spelling, or create a new account.',
'nosuchusershort' => 'There is no user by the name "<nowiki>$1</nowiki>".