Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Cristian Antohe

    (@sareiodata)

    Hi,

    That’s because User Domain Whitelist doesn’t know about Profile Builder.

    I’ll do some research the following days to see if I can easily build a bridge between the two plugins.

    I also see that you send us an email over at cozmoslabs.com

    If it’s ok with you, I would like to discuss this here in case someone else might need the same thing.

    I’ll have an update the next couple of days regarding this.

    Hi Sareiodata,

    Did you end up figuring out how to use User Domain Whitelist with the latest version of Profile Builder? I saw filters for a previous version of Profile Builder but they don’t work with v2.

    Thanks,
    Bryce

    Plugin Author Cristian Antohe

    (@sareiodata)

    Can you please send me the link where you saw the User Domain Whitelist filters in PB 1.3.x?

    I tried to search for something like this but couldn’t find anything. (I vaguely remember working something like this).

    What I can do is a custom code that will not block certain domains to register.

    /*
     * Block certain email domains from registering
     */
    function wppb_check_email_domain( $message, $field, $request_data, $form_location ){
    	$list_of_blocked_domains = array( 'domain.com', 'mail.com', );
    	//$domain = array_pop(explode('@', $request_data['email']));
    	$domain = substr(strrchr($request_data['email'], "@"), 1);
    	if ( in_array( $domain, $list_of_blocked_domains) ) {
    		return __( 'The email domain you entered is not allowed on this website. Please try with a different email address.', 'profilebuilder' );
    	}
    
    	return $message;
    }
    add_filter( 'wppb_check_form_field_default-e-mail', 'wppb_check_email_domain', 20, 4 );

    Then add to your $list_of_blocked_domains the domains you want blocked.

    Please note this will work for Profile Builder registration and edit-profile forms.

    Thank you, I will try this. Here is the old post that has the v1.x filters: https://www.cozmoslabs.com/forums/topic/user-domain-whitelistbacklist-only-all-emails-from-domain/

    I actually need a *whitelist* ability, not a blacklist, which is what it looks like you coded there. So I want to be able to set the rule that only people with emails that have “@sample.com” can register. Do you have something that could work for a whitelist instead?

    Thank you,
    Bryce

    Plugin Author Cristian Antohe

    (@sareiodata)

    That’s fairly simple.

    /*
     * Block certain email domains from registering
     */
    function wppb_check_email_domain( $message, $field, $request_data, $form_location ){
    	$list_of_blocked_domains = array( 'domain.com', 'mail.com', );
    	//$domain = array_pop(explode('@', $request_data['email']));
    	$domain = substr(strrchr($request_data['email'], "@"), 1);
    	if ( !in_array( $domain, $list_of_blocked_domains) ) {
    		return __( 'The email domain you entered is not allowed on this website. Please try with a different email address.', 'profilebuilder' );
    	}
    
    	return $message;
    }
    add_filter( 'wppb_check_form_field_default-e-mail', 'wppb_check_email_domain', 20, 4 );

    I just changed the condition to not in_array.

    As for the 1.x filters, yes, those won’t work in 2.0.

    Thanks for this reply. I’ve put that code in the “profile builder customizations” plugin, but it doesn’t seem to be working. I noticed in profile-builder/front-end/default-fields/email/email.php that the sequence for triggering ‘wppb_check_form_field_default-e-mail’ and ‘wppb_check_email_value’ are 10 and 4, respectively. So I tried changing the sequence of the whitelist code you provided to “add_filter( ‘wppb_check_form_field_default-e-mail’, ‘wppb_check_email_domain’, 3, 3 );”, but that didn’t work either. Any ideas? Thanks for your help.

    Plugin Author Cristian Antohe

    (@sareiodata)

    I personally tested this and it worked for me. 20, 4 is the correct values to pass to the add_filter call.

    I’m really not sure why it wouldn’t work.

    Try again with the first code (domain blacklist) and see if that code works, then if it dose, it means something’s wrong with the second one I sent.

    Looks like it works now! Thanks for your help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘User Domain Whitelist not worked on Profile Builder!’ is closed to new replies.