wpnzach
5/14/2015 - 2:23 PM

bad domain msg

bad domain msg

<?php
function custom_nf_verify_email_domain(){
  global $ninja_forms_processing;
  // Gets the ID of the form we are currently processing.
  $form_id = $ninja_forms_processing->get_form_ID();   
  if ($form_id == 13) {
    // Get the user submitted value for the field with an ID of 55.
    $submitted_email = $ninja_forms_processing->get_field_value( 55 );
    // Set the allowed domain that we will accept.
    $approved_email = '@gmail.com';    
      if !strpos( $submitted_email , $approved_email ) {        
          $ninja_forms_processing->add_error( 'bad_email_domain' , 'Your email domain is not authorized for registration' , 'general' ); 
      }      
  }  
}
  
add_action( 'ninja_forms_pre_process' , 'custom_nf_verify_email_domain' );