This topic has 2 replies, 3 voices, and was last updated 8 years by Whoweez.

  • Author
  • #1220
     djgelato
    Participant

    Hello, is it possible to set a domain extension requirement during the signup process? For example, I want only people that have an email based out of the uk so it will only accept emails that end in @whatever.co.uk or @whatever.eu, is this possible?

    Thanks

    #1227
     SQadmin
    Keymaster

    Hi,
    Yes it is.
    Just add this snippet to your sweetdate-child/functions.php file under wp-content/themes:

    COPY CODE
    
    function bp_restrict_email_domains_validate_user_signup( $result ) {
    
    	if ( bp_restrict_email_domains_is_email_address_safe( $result['user_email'] ) )
    		$result['errors']->add('user_email',  __('You cannot use that email address to signup.', 'kleo_framework' ) );
    
    	return $result;
    
    }
    add_filter( 'bp_core_validate_user_signup', 'bp_restrict_email_domains_validate_user_signup' );
    
    function bp_restrict_email_domains_is_email_address_safe( $user_email ) {
    
    	$allowed_names = array(
            '.co.uk',
            'gmail.com'
        );
    	
    	if ( is_array( $allowed_names )) {
    	
    		$email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
    		
    		foreach ( (array) $allowed_names as $allowed_domain ) {
    		
    			if ( strstr( $email_domain, $allowed_domain ) ||
    				(
    					strstr( $allowed_domain, '/' ) AND
    					preg_match( $allowed_domain, $email_domain )
    				)
    			)
    			return false;
    		}
    		
    	}
    	return true;
    }
    
    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #62687
     Whoweez
    Participant

    Good day,

    Does this include the process followed via signing up for a PMPro membership level.

    I.e. I’d like visitor to signup for PMPro buddypress level (pmpro access to buddypress) – thus restricting only certain domain names to have access…

    Please let me know if this is possible.

    Thanks so much 🙂
    Whoweez

Viewing 3 posts - 1 through 3 (of 3 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?