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
if ( !function_exists( 'ninja_forms_field_spam_pre_process' ) ) { require_once ABSPATH . PLUGINDIR . 'ninja-forms/deprecated/includes/fields/spam.php'; } // The field id. $field_id = null; // The user value. $user_value = null; // NOTICE! Understand what this does before running. $result = ninja_forms_field_spam_pre_process($field_id, $user_value);
Defined (1)
The function is defined in the following location(s).
- /deprecated/includes/fields/spam.php
- function ninja_forms_field_spam_pre_process( $field_id, $user_value ) {
- global $ninja_forms_processing;
- $plugin_settings = nf_get_settings();
- if(isset($plugin_settings['spam_error'])) {
- $spam_error = __( $plugin_settings['spam_error'], 'ninja-forms' );
- }
- $field_row = ninja_forms_get_field_by_id($field_id);
- $field_data = $field_row['data'];
- $spam_answer = $field_data['spam_answer'];
- $form_row = ninja_forms_get_form_by_field_id($field_id);
- $form_id = $form_row['id'];
- 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) {
- if( is_object( $ninja_forms_processing)) {
- if( $user_value != '' ) {
- $ninja_forms_processing->add_error('spam-general', $spam_error, 'general');
- $ninja_forms_processing->add_error('spam-'.$field_id, $spam_error, $field_id);
- }
- }
- }
- }