How To Edit the MediaWiki Login Page

August 21, 2010

in Mediawiki

On the SammyWiki site I use both vBulletin and Mediawiki. The two packages have been setup so that there is a single sign on using the vBulletin authentication system.

For those interested I am currently using this single sign on extention.  Although I am considering using this one.

This works very well but users can only login via vBulletin, the Mediawiki login page becomes redundant. Although it is possible to switch off user registration in Mediawiki, I couldn’t find a way to prevent people from trying to login through the Special:UserLogin page.

I considered two solutions:

  • Remove the login link. However this link becomes logout and that still works. Also without the login link users might not know how to get access to the site!
  • Remove the login username/password boxes. This way I could still have the login page, which would have links to the vBulletin login and registration pages, but users would no longer try to get access through MediaWiki.

Creating a MediaWiki Extention to Edit the SpecialUserLogin page

MediaWiki extensions are brand new to me so this was my first ever attempt. Fortunately the developers have provided us with a whole range of hooks that allow us to modify almost anything!

Here is the basic test extention that I created:

<?php

$wgHooks['UserLoginForm'][]      = ‘onUserLoginForm’;

function onUserLoginForm($template)
{
$template->set( ‘name’, ‘!’ );
$template->set( ‘password’, ‘?’ );

$template->data['message'] = ‘JEZTEST’;
$template->data['messagetype'] = ‘error’;
return true;}

?>

And to get this to run, call it from within LocalSettings.php:

require_once( “$IP/extensions/yourextensionfile.php”)

Editing the LoginForm Template

Although my basic extention worked, I couldn’t see how to make changes to the actual form template. If anyone knows how to do this, please let me know!

So plan b was to edit the template directly and remove the login boxes.

This solution isn’t quite so good as I will need to replicate the change anytime I upload and overwrite the template with a new version of MediaWiki, but it will do the job for now.

The file to edit is:

\includes\templates\Userlogin.php

You’ll see where the name and password boxes are generated by searching for “Html::input”

Editing the MediaWiki Login Page Text Message

Pretty much any message in your MediaWiki installation can be edited, and the text displayed on the user login special page is no exception.

Generally, to make any edits to messages, go to Special Pages->System Messages

This should take you to the wiki/Special:AllMessages page. Here you need to search for and locate the “loginprompt” message.  Note that you need to have the correct user rights to edit this.

Related posts:

  1. WordPress PHPBB3 and MediWiki shared login
  2. MediaWiki 1.16 Stable is Finally Released

{ 2 comments… read them below or add one }

Benor May 13, 2011 at 1:48 pm

Hi Jezza101,

I had got the same Problem as you.
The Solution: I’ve found an Extension for MediaWiki which replaces the “UserLoginForm” or “UserCreateForm” by your custom Form as requested.
[http://www.mediawiki.org/wiki/Extension:CustomUserCreateForm]
You make a copy of “includes/templates/Userlogin.php” like in the abovementioned instructions and edit the File as you like, e.g. deleting the CreateForm or LoginForm and print a link to another Loginpage of “vBulletin”. On the other Hand it could be possible to register in both Systems by your custom Form.
Be creative!!!

Regards
Ben

jezza101 May 17, 2011 at 8:35 am

Thanks very much for that – I’ll have to try it out, I haven’t done much with my wiki for a while but next time I’m doing some improvements….

Leave a Comment

Previous post:

Next post: