Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Limit registrations to specific emails/domains.

AnonymooseAnonymoose ✭✭
edited October 2011 in Vanilla 2.0 - 2.8
Looking for someone to point me in the right direction on how to write an addon to limit registrations from a specific domain, ie. only for example.

Best Answer


  • Options

    @Anonymoose, did you build a plugin with todd's Code? I would like to use it! :)

  • Options

    Sorry, not yet.

  • Options

    Hmm, i dont know where to put the code from Todd. :(

  • Options

    inside Google Sign In plugin, or whatever authentication plugin you are using

  • Options
    AnonymooseAnonymoose ✭✭
    edited October 2012

    Now trying to build my first plugin for Vanilla. Coming up with this:

    Parse error: syntax error, unexpected '{' in /home/forum/html/plugins/LimitRegistrations/default.php on line 19

    This is the line: if (!StringEndsWith($User['Email'], '') {

    not sure why. The other { } are balanced...

    <?php if (!defined('APPLICATION')) exit();
    // Define the plugin:
    // the 'LimitRegistrations' is the name of the Plugin folder
    $PluginInfo['LimitRegistrations'] = array(
        // just the name to display of the plugin below
        'Name' => 'LimitRegistrations',
        // a brief description
        'Description' => 'This plugin limits registrations to specific domains.',
        // each time you update plugin update version so you can upload it.
        'Version' => '1.0',
        'Author' => "Anonymoose"  // the author
    class LimitRegistrations extends Gdn_Plugin {
    public function UserModel_BeforeRegister_Handler($Sender, $Args) {
       $User = $Args['User'];
       if (!StringEndsWith($User['Email'], '') {
          $Sender->Validation->AddValidationResult('Email', 'We only allow people from');
          $Args['Valid'] = FALSE;
        // this allows you to enable and disable plugin
      public function Setup() {
    //class LimitRegistrations
  • Options
    AnonymooseAnonymoose ✭✭
    edited October 2012


    Changing line 19 to this:

    if (!(preg_match("/$/i", $User['Email']))) {

  • Options

    @wiesson said:
    Anonymoose, did you build a plugin with todd's Code? I would like to use it! :)

    Yes. After all, I did, and it is now posted as the LimitRegistrations plugin. The next step might be to add more features like limiting registrations by IP and so on and to add configuration form the dashboard. Otherwise, it just works.

  • Options

    At which line to add fake email

  • Options
    ligyxyligyxy New
    edited November 2016

    @Anonymoose the plugin need update for vanilla 2.3
    @Todd Could you also take a look? the piece of code might not work under 2.3

  • Options

    Never mind, just replace $User['Email'] above into $Args['RegisteringUser']['Email']

Sign In or Register to comment.