Skip to:
Content
Pages
Categories
Search
Top
Bottom

Domain whitelist for buddypress signup


  • lfeddern
    Participant

    @lfeddern

    am trying to add a domain whitelist to the buddypress registration.

    all of the email address that will sign up to on my site will have the domain form @XX.yo.ac.uk with the XX varying in character length and number characters themselves.

    I basically would like to strip the domain of the entered email address down to the last 9 characters and then compare them to (.yo.ac.uk) and return an error message if not identical, if not then allow the registration to continue.

    I found this code:

    // ====================================
    // Limit signup by banning domains
    function bp_as_restrict_signup_domains( $result ) {
    
     $banned = array(
     'spam1.com',
     'spam2.com'
     );
     $error = 'Your email domain has been the source of spam. Please use another email address.';
    
     $email = $result['user_email'];
     $domain = array_pop(explode('@', $email));
    if ( in_array($domain, $banned))
     {
     $result['errors']->add('user_email', __($error, 'bp-restrict-email-domains' ) );
     };
     return $result;
    }
    add_filter( 'bp_core_validate_user_signup', 'bp_as_restrict_signup_domains' );

    here: http://alexschreyer.net/programming/limit-buddypress-registration-by-domain/

    But this is to block certain domains rather than allow. Any ideas how to change it? and to strip out the characters before the last 9?

    Thanks for any help!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Domain whitelist for buddypress signup’ is closed to new replies.
Skip to toolbar