Skip to content

Instantly share code, notes, and snippets.

@zachskaggs
Last active August 29, 2015 14:21
Show Gist options
  • Save zachskaggs/9d5299c3970604a4b5b5 to your computer and use it in GitHub Desktop.
Save zachskaggs/9d5299c3970604a4b5b5 to your computer and use it in GitHub Desktop.
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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment