Extension:ForceLogin
This extension is currently not actively maintained! Although it may still work, any bug reports or feature requests will more than likely be ignored. |
This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net . |
ForceLogin Release status: unmaintained |
|
---|---|
Implementation | MyWiki |
Description | Forces login on Edit action of a page and redirects user back to the edit page on login. |
Author(s) | Kuldeep Ghogre, Manit Hirani (manithiranitalk) |
Latest version | 1.0 (2013-02-06) |
MediaWiki | 1.23+ |
PHP | 5.3+ |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | See the code section |
The ForceLogin extension forces login on Edit action of a page and redirects user back to the edit page on login.
InstallationEdit
- Copy the code into a file and place the file(s) in a directory called
ForceLogin
in yourextensions/
folder. - Add the following code at the bottom of your LocalSettings.php:
require_once "$IP/extensions/ForceLogin/ForceLogin.php";
- Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
CodeEdit
- ForceLogin.php
<?php
/**
* ForceLogin extension
* @file ForceLogin.php
* @version 1.0
* @author Manit Hirani (manithirani)
* @author Kuldeep Ghogre
* @link https://www.mediawiki.org/wiki/Extension:ForceLogin
* @license GPL-2.0-or-later
*/
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
$wgExtensionCredits['other'][] = array(
'path' => __FILE__,
'name' => 'ForceLogin',
'author' =>array('Manit Hirani','Kuldeep Ghogre'),
'description' => 'Redirects to login page on edit action',
'url' => 'https://www.mediawiki.org/wiki/Extension:ForceLogin',
'version' => 1.0,
'license-name' => 'GPL-2.0-or-later'
);
$wgHooks['AlternateEdit'][]='redirectOnEdit';
function redirectOnEdit($editPage){
global $wgUser, $wgOut, $wgTitle, $wgScriptPath;
if(!$wgUser->isLoggedIn()){
$wgOut->redirect($wgScriptPath.'/index.php?title=Special:UserLogin&returnto='.$wgTitle.'&returntoquery=action%3Dedit');
}
return true;
}