David Stockdale's Scrapcode

Restrict User Registration on a Miraheze Wiki to a Specific Domain

“David, let me ask you something more. Is it possible to restrict registering the wiki to users being part of my school? I mean, all users who register to my wiki, must have the domain email ‘itsos-mariecurie.it’? Thank for help”

Daniele Ramon

After lots of searching this doesn’t seem to be a function ever even considered by Miraheze.

The closest thing I found was a similar question about MediaWiki (which Miraheze uses a version of) that requires quite a bit of code that is likely out of date:

https://www.mediawiki.org/wiki/Topic:R6yicvckeu8b6idb

https://www.mediawiki.org/wiki/Topic:Rg8scj0rl4iqulmg

Other than that the focus seems to be on blocking specific users and IP addresses.

Supposedly it is possible to restrict the registration of new users on a Miraheze wiki to only allow users with a specific email domain such as ‘itsos-mariecurie.it’.

This can be achieved through custom configuration and extensions.

Here’s a (untested) step-by-step guide that might work:

Step 1: Request Extension Activation

  1. Go to Miraheze Phabricator (https://phabricator.miraheze.org).
  2. Log in with your Miraheze account.
  3. Create a new task requesting the activation of the ConfirmEdit extension for your wiki.

Step 2: Configure Email Domain Restriction

After the ConfirmEdit extension is enabled, you can configure it to restrict email domains.

  1. Add Configuration to LocalSettings.php: You will need to add some lines to your LocalSettings.php to restrict the email domain. This is typically done by Miraheze staff based on your request.

Here is an example configuration:

// Enable ConfirmEdit extension
wfLoadExtension( 'ConfirmEdit' );

// Configure ConfirmEdit to use ReCaptcha (optional, you might not need this if only restricting by domain)
$wgCaptchaClass = 'ReCaptcha';
$wgReCaptchaSiteKey = 'your-site-key';
$wgReCaptchaSecretKey = 'your-secret-key';

// Restrict email domain
$wgHooks['AbortNewAccount'][] = function ( $user, &$message ) {
    $allowedDomain = 'itsos-mariecurie.it';
    $email = $user->getEmail();
    if ( $email && !str_ends_with( $email, '@' . $allowedDomain ) ) {
        $message = "Registration is restricted to emails from $allowedDomain domain.";
        return false;
    }
    return true;
};
  1. Submit Configuration Request: Submit a request to Miraheze support via Phabricator to add this configuration to your LocalSettings.php. Provide the exact lines of code and explain that you want to restrict user registrations to a specific email domain.

Step 3: Verify Configuration

After the configuration is added by Miraheze staff, you should test the registration process to ensure that it correctly restricts new user registrations to the ‘itsos-mariecurie.it’ domain.

Example Request to Miraheze Support

Here is a template you can use to request the necessary configuration changes:

Subject: Request to Restrict User Registrations by Email Domain

Dear Miraheze Support,

I would like to request assistance in configuring my wiki to restrict new user registrations to only allow email addresses from the ‘itsos-mariecurie.it’ domain. Here are the details of the configuration I need:

– Enable the ConfirmEdit extension.
– Add the following configuration to LocalSettings.php to enforce the email domain restriction:

// Enable ConfirmEdit extension
wfLoadExtension( 'ConfirmEdit' );

// Restrict email domain
$wgHooks['AbortNewAccount'][] = function ( $user, &$message ) {
    $allowedDomain = 'itsos-mariecurie.it';
    $email = $user->getEmail();
    if ( $email && !str_ends_with( $email, '@' . $allowedDomain ) ) {
        $message = "Registration is restricted to emails from $allowedDomain domain.";
        return false;
    }
    return true;
};

Thank you for your support.

Best regards, [Your Name] [Your Wiki URL]

By following these steps, you might be able to restrict the registration of new users on your Miraheze wiki to those with an email address from the specified domain.

Hope this made your Google search a bit shorter, leave a comment if this helped or you have any specific problems you need a solution to.

Leave a Reply