Extension:RedirectAfterLogout

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
RedirectAfterLogout

Release status: stable

Implementation User activity
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"
Parameters

$wgPageToRedirectAfterLogout

Hooks used
UserLogout
Check usage and version matrix; stats

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

Compatibility[edit]

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
  • 1.11.0
  • 1.17
  • 1.13
  • ... (please add other tested versions)

Extension call[edit]

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";

Extension code[edit]

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;
}
?>

Similiar extensions[edit]