ninja_forms_field_spam_pre_process

The Ninja Forms ninja forms field spam pre process function.

Description

ninja_forms_field_spam_pre_process( $field_id, $user_value ); 

Parameters (2)

0. $field_id
The field id.
1. $user_value
The user value.

Usage

  1. if ( !function_exists( 'ninja_forms_field_spam_pre_process' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/spam.php'; 
  3.  
  4. // The field id. 
  5. $field_id = null; 
  6.  
  7. // The user value. 
  8. $user_value = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = ninja_forms_field_spam_pre_process($field_id, $user_value); 
  12.  

Defined (1)

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

/deprecated/includes/fields/spam.php  
  1. function ninja_forms_field_spam_pre_process( $field_id, $user_value ) { 
  2. global $ninja_forms_processing; 
  3.  
  4. $plugin_settings = nf_get_settings(); 
  5. if(isset($plugin_settings['spam_error'])) { 
  6. $spam_error = __( $plugin_settings['spam_error'], 'ninja-forms' ); 
  7. $field_row = ninja_forms_get_field_by_id($field_id); 
  8. $field_data = $field_row['data']; 
  9. $spam_answer = $field_data['spam_answer']; 
  10.  
  11. $form_row = ninja_forms_get_form_by_field_id($field_id); 
  12. $form_id = $form_row['id']; 
  13.  
  14. if( $ninja_forms_processing->get_action() != 'save' AND $ninja_forms_processing->get_action() != 'mp_save' AND !isset($_POST['_wp_login']) AND $user_value != $spam_answer) { 
  15. if( is_object( $ninja_forms_processing)) { 
  16. if( $user_value != '' ) { 
  17. $ninja_forms_processing->add_error('spam-general', $spam_error, 'general'); 
  18. $ninja_forms_processing->add_error('spam-'.$field_id, $spam_error, $field_id);