User:Rob Kam/sandbox

From Miraheze Developers Wiki
Jump to navigation Jump to search

This explains the steps for creating a Gadget which redirects anonymous users to create an account via Miraheze Login Wiki. The gadget adds a "Create account" link on the personal toolbar (top right) before the Log in link.

On your wiki:

1. Use Special:ManageWiki/permissions for group * (anonymous users) to uncheck all options except 'editmyprivateinfo' (to still allow logged out users to reset their password).

2. Create page MediaWiki:Gadget-createlogin.js with the following code:

/* Add (only for anonymous users) a "Create account" link to the personal toolbar. */
mw.loader.using( [ 'mediawiki.user', 'mediawiki.util' ], function () {
  if ( mw.user.isAnon() ) {
    var newElement = mw.util.addPortletLink(
       'p-personal',
       'https://login.miraheze.org/wiki/Special:CreateAccount',
       'Create account',
       'pt-create',
       'Create an account to edit',
       null,
       '#pt-login'
    );
  }
} );

3. At page MediaWiki:Gadgets-definition add the line:

* Create login[ResourceLoader|default|hidden]|createlogin.js

4. At page MediaWiki:Gadget-Create login add the line:

Add (only for anonymous users) a "Create account" link to the personal toolbar.

See also[edit]