• Resolved ozmatflc

    (@ozmatflc)


    I want to only allow subscriptions from a single domain. Is there a way to invert the option in the blocked domain(s) field?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Shubhanshu Kandani

    (@shubhanshukandani)

    Hi @ozmatflc,

    Thank you for reaching out, we’re glad to assist you.

    While achieving this directly through the plugin’s inbuilt options isn’t possible, it can be accomplished through custom PHP code.

    Below is an example of how to do it:

    add_filter( 'ig_es_validate_subscribers_data', 'exp_cc_allow_subscription_from_allowed_domain_list' );
    
    function exp_cc_allow_subscription_from_allowed_domain_list( $data ) {
    	$form_data = wp_unslash( $_POST );
    	if ( ! empty( $form_data['esfpx_email'] ) ) {
    		$email        = $form_data['esfpx_email'];
    		$rev_email = strrev( $email );
    		$allowed_domains = array(
    			'example.com'
    		);
    		$domain_allowed = false;
    		foreach ( $allowed_domains as $domain ) {
    			$domain = trim( $domain );
    			if ( ! empty( $domain ) && strpos( $rev_email, strrev( $domain ) ) === 0 ) {
    				$email_parts = explode( '@', $email );
    				if ( ! empty( $email_parts[1] ) ) {
    					$email_domain = $email_parts[1];
    					if ( $email_domain === $domain ) {
    						$domain_allowed = true;
    						break;
    					}
    				}
    			}
    		}
    		if ( ! $domain_allowed ) {
    			$data = array( 'status' => 'ERROR', 'message' => 'es_email_address_blocked' );
    			return $data;
    		}
    	}
    
    	return $data;
    }

    Note: Change allowed domain list in the $allowed_domains variable according to the requirements.

    You can use the above code into the functions.php file of your currently active child theme or use the “Code Snippets” plugin for easy integration.

    Let me know how it goes on your side.

    Cheers!

    Plugin Contributor Shubhanshu Kandani

    (@shubhanshukandani)

    Hi @ozmatflc ,

    Hope you’re doing great.

    I wanted to check in with you regarding the inquiry you had the other day. Was it resolved? Do you need any additional help? I’d be happy to assist you in any case.

    Thank you!
    Have a great day ahead.

    Plugin Contributor Shubhanshu Kandani

    (@shubhanshukandani)

    Hi?@ozmatflc,

    We hope our previous replies were helpful in resolving your inquiry.

    I am closing this thread for now. Feel free to reopen it in case if you are still having issues or inquiries related to the plugin.

    Also if you have any other queries, you can open a new thread from here. We will be happy to assist you further.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.