Extension:RedirectOnLogin

From MediaWiki.org

Jump to: navigation, search
Crystal Clear app error.png

This extension is obsolete!
It has been replaced by core functionality in the MediaWiki software (which was added in version 1.15.0).

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
RedirectOnLogin

Release status: stable

Description Allows wiki administrators to redirect to a specific page when an user login
Author(s)  User:DarkonekoTalk
Last Version  1.1 (30/07/2008)
MediaWiki  tested on 1.12.0 (1.4+ theorically)
License pubblic domain
Download Extension:RedirectOnLogin#Extension_code

check usage (experimental)

This little extension allow you, when an user login successfully, to redirect him directly to a page of your choice instead of the usual "you are now logged in" page.

Contents

[edit] Compatibility

This was created for MW 1.12.0 and is currently untested on others (please update this page when you try it on other versions), but it should work fine as long as the 'UserLoginComplete' hook (1.4+) and $wgOut->redirect() exists.

Tested on
  • 1.12.0
  • 1.13.1
  • 1.14

[edit] Extension call

//absolute path from web root. Can also be an URL
require_once("extensions/redirectOnLogin.php");
$wgPageToRedirectOnLogin = "/path_to_mediawiki/index.php?title=yourpage";

[edit] Extension code

Create a page at "extensions/redirectOnLogin.php" with the following content

<?php
//not called from the software = no can do.
if( ! defined( 'MEDIAWIKI' ) ) {
    echo( "This file is an extension to the MediaWiki software, and cannot be used standalone.\n" );
    die( 1 );
}
 
$wgExtensionCredits['other'][] = array(
    'name'=>'redirectOnLogin',
    'version'=> '1.1',
    'author'=>'Wolfgang ten Weges', // [[fr:user:Darkoneko]]
    'url'=>'http://www.mediawiki.org/wiki/Extension:RedirectOnLogin',
    'description' => 'Redirect to any page you want on login'
);
 
//URL to redirect on successful login
$wgPageToRedirectOnLogin = '';
 
$wgHooks['UserLoginComplete'][] = 'redirectOnLogin';
 
function redirectOnLogin(&$user) {
        global $wgOut, $wgPageToRedirectOnLogin;
        $wgOut->redirect( $wgPageToRedirectOnLogin );
 
        return true;
}

[edit] Similiar extensions