wpcf7_is_email_in_domain

The Contact Form 7 wpcf7 is email in domain function.

Description

wpcf7_is_email_in_domain( $email, $domain ); 

Parameters (2)

0. $email
The email.
1. $domain
The domain.

Usage

  1. if ( !function_exists( 'wpcf7_is_email_in_domain' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'contact-form-7/includes/formatting.php'; 
  3.  
  4. // The email. 
  5. $email = null; 
  6.  
  7. // The domain. 
  8. $domain = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wpcf7_is_email_in_domain($email, $domain); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/formatting.php  
  1. function wpcf7_is_email_in_domain( $email, $domain ) { 
  2. $email_list = wpcf7_is_mailbox_list( $email ); 
  3. $domain = strtolower( $domain ); 
  4.  
  5. foreach ( $email_list as $email ) { 
  6. $email_domain = substr( $email, strrpos( $email, '@' ) + 1 ); 
  7. $email_domain = strtolower( $email_domain ); 
  8. $domain_parts = explode( '.', $domain ); 
  9.  
  10. do { 
  11. $site_domain = implode( '.', $domain_parts ); 
  12.  
  13. if ( $site_domain == $email_domain ) { 
  14. continue 2; 
  15.  
  16. array_shift( $domain_parts ); 
  17. } while ( $domain_parts ); 
  18.  
  19. return false; 
  20.  
  21. return true;