Extension:RedirectAfterLogout

From MediaWiki.org

Jump to: navigation, search

           

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

Release status: stable

Description Allows wiki administrators to redirect to a specific page after a user has logged out
Author(s)  User:MaziminkeTalk
Last Version  1.0 (01/12/2008)
MediaWiki  tested on 1.14a
License public domain
Download see "Extension code"

check usage (experimental)

This is an adaption of the RedirectOnLogin extension which allows you to redirect a user to a certain wiki page after having logged out.

Contents

[edit] Compatibility

The extension was created for MW 1.14a and is currently untested on others. Nevertheless this extension should work fine on all mediawikis which support UserLogout hook and $wgOut->redirect().

Please update this page when you have tested the extension on other versions.

Tested on
  • 1.14
  • ... (please add other tested versions)

[edit] Extension call

Please add the following lines to your Localsettings.php file and adapt them:

//absolute path from web root
require_once("extensions/redirectAfterLogout.php");
 
//wiki page to redirect to (adjust path and page title)
$wgPageToRedirectAfterLogout = "/path_to_mediawiki/index.php?title=yourpage";

[edit] Extension code

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

<?php
//not called from the software -> show warning
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'=>'redirectAfterLogout',
    'version'=> '1.0',
    'author'=>'Marcel Minke', // [[de:user:Maziminke]]
    'url'=>'http://www.mediawiki.org/wiki/extensions:RedirectAfterLogout',
    'description' => 'Redirect to a certain page after logout'
);
 
 
 
//wiki page to redirect to (adjust path and page title)
$wgPageToRedirectAfterLogout = "/path_to_mediawiki/index.php?title=yourpage"; 
 
$wgHooks['UserLogout'][] = 'redirectAfterLogout';
 
function redirectAfterLogout(&$user) {
        global $wgOut, $wgPageToRedirectAfterLogout;
        $wgOut->redirect( $wgPageToRedirectAfterLogout );        
 
        return true;
}
?>

[edit] Similiar extensions