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.

Restrict email domains

edited July 2011 in Vanilla 2.0 - 2.8
Hi, I want to restrict the user registration to an specific domain (for example only @gmail.com), is there any way to do this?

Thank you!

Comments

  • LincLinc Detroit Admin
    edited July 2011
    Requires a custom plugin. You'll want to hook into the 'BeforeRegister' event (using a method named UserModel_BeforeRegister_Handler). The Email will be in the array $this->EventArguments['User']. Compare it to the doman you want to restrict it to, and if it fails set $this->EventArguments['Valid'] to false.

    Plugin quickstart: http://vanillaforums.org/docs/pluginquickstart
  • I tried this but doesn't work

    class MyMembershipPlugin extends Gdn_Plugin {

    public function UserModel_BeforeRegister_Handler($Sender) {
    $email = $this->EventArguments['User'][Email];
    if (strstr($email, '@mydomain.com') === false) {
    $this->EventArguments['Valid'] = false;
    }
    }

    }

    I don't know where is the email. I tried print_r($this->EventArguments['User']) to get the user email but it shows nothing because i'm redirected to home. So this is not working at all. Can you help me please? I'm lost.
Sign In or Register to comment.