Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

Restricting Membership by Email Domain . . .

edited August 2006 in Vanilla 1.0 Help
Before I start delving into the vexed question of how to do this, I would like to know if anybody else has first. Specifically, I would like to restrict membership to a forum to email addresses for a given domain (e.g. example.org). If nobody has implemented this yet, if you'll give me a nudge in the right direction, I'll take it on. Regards, Ben Wilson

Comments

  • Options
    A dirty and not completely foolproof way to do it is change line 194 in Library>Framework>People>People.Class.UserManager.php

    Validate($this->Context->GetDefinition('EmailLower'), 1, $SafeUser->Email, 200, '(.+)@(.+)\.(.+)', $this->Context);

    to

    Validate($this->Context->GetDefinition('EmailLower'), 1, $SafeUser->Email, 200, '(.+)@(gmail)\.(com)', $this->Context);

    where "gmail" and "com" is the domain you want to require.

    This is also probably something that will get overwritten if/when you update Vanilla.
  • Options
    You can use the PostValidation delegation in the CreateUser function of the UserManager class for this validation, and it won't be overwritten with an update.
  • Options
    Not to be a newb, Dinoboff, but how exactly would you go about it that way? Would you need to write an extension?

    Sorry for the lamer question, but the more I understand this app, the better. And as of now (as I'm sure you can tell) it's all a bit of a mystery to me.
  • Options
    edited August 2006
    Yep, an extension:
    ... function GoogleMemberOnly(&$UserManager) { $User= &$UserManager->DelegateParameters['User']; Validate($UserManager->Context->GetDefinition('EmailLower'), 1, $User->Email, 200, '(.+)@(gmail)\.(com)', $UserManager->Context); } $Context->AddToDelegate('UserManager', 'PostValidation ', 'GoogleMemberOnly');
  • Options
    I'm having troubling implementing this solution. Can someone help me?

    Following Dinoboff's suggestion, I created this php file:

    <?php
    /*
    Extension Name: RestrictMembership
    Extension Url: http://vanillaforums.org/discussion/comment/40894/#Comment_40894
    Description: Restricts membership to only those with an @gmail.com email address.
    Version: 0.1
    Author: Dinoboff
    Author Url: http://vanillaforums.org/profile/Dinoboff
    */

    function GoogleMemberOnly(&$UserManager) { $User= &$UserManager->DelegateParameters['User'];

    Validate($UserManager->Context->GetDefinition('EmailLower'), 1, $User->Email, 200, '(.+)@(gmail)\.(com)', $UserManager->Context); }

    $Context->AddToDelegate('UserManager', 'PostValidation ', 'GoogleMemberOnly');

    ?>

    I called it default.php and added it to its own folder ("RestrictMembership") in the extensions folder. I changed all appearances of "gmail" and "com" to the only email domain that should be allowed.

    The extension shows up where it should on the Vanilla extensions page, and Vanilla allows me tick the box enabling it. But when I tested it by attempting to sign up as a new member with a domain other than the one I changed "gmail.com" to, I was allowed in. What did I forget to do?
Sign In or Register to comment.