Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'forminator_custom_form_submit_errors', function( $submit_errors, $form_id, $field_data_array ){
- $your_list_forms = [22246];
- if ( empty( $submit_errors ) && in_array( $form_id, $your_list_forms ) ) {
- $submitted_fields = wp_list_pluck( $field_data_array, 'value', 'name' );
- if ( empty( $submitted_fields['checkbox-2'] ) ) {
- return $submit_errors;
- }
- $your_unique_field_name = 'email-2';
- $your_unique_field_phone = 'phone-2';
- $your_error_msg = 'There is no application in progress with the given data / A megadott adatokkal nincs folyamatban lévő jelentkezés';
- $GLOBALS['reg_error'] = false;
- foreach ( $field_data_array as $field ) {
- if ( $field['name'] === $your_unique_field_name ) {
- global $wpdb;
- $table_meta = $wpdb->prefix . 'frmt_form_entry_meta';
- $table_entry = $wpdb->prefix . 'frmt_form_entry';
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(1) FROM $table_meta as m LEFT JOIN $table_entry as e ON m.entry_id = e.entry_id WHERE m.meta_key = %s AND m.meta_value=%s AND e.form_id = %d LIMIT 1;", 'email-1', $field['value'], $form_id ) ) ) {
- $submit_errors[]['submit'] = $your_error_msg;
- $GLOBALS['reg_error'] = true;
- break;
- }
- }
- if ( $field['name'] === $your_unique_field_phone ) {
- global $wpdb;
- $table_meta = $wpdb->prefix . 'frmt_form_entry_meta';
- $table_entry = $wpdb->prefix . 'frmt_form_entry';
- if ( ! $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(1) FROM $table_meta as m LEFT JOIN $table_entry as e ON m.entry_id = e.entry_id WHERE m.meta_key = %s AND m.meta_value=%s AND e.form_id = %d LIMIT 1;", 'phone-1', $field['value'], $form_id ) ) ) {
- $submit_errors[]['submit'] = $your_error_msg;
- $GLOBALS['reg_error'] = true;
- break;
- }
- }
- }
- }
- return $submit_errors;
- }, 10, 3);
- add_filter( 'forminator_custom_form_invalid_form_message', 'wpmudev_invalid_form_error_response', 10, 2 );
- function wpmudev_invalid_form_error_response( $invalid_form_message, $form_id ){
- if ( $form_id != 22246 ) {
- return $invalid_form_message;
- }
- if ( $GLOBALS['reg_error'] ) {
- $invalid_form_message = __( 'There is no application in progress with the given data / A megadott adatokkal nincs folyamatban lévő jelentkezés', 'forminator' );
- }
- return $invalid_form_message;
- }
Advertisement
Add Comment
Please, Sign In to add comment