| @@ -109,10 +109,8 @@ | ||
| 109 | 109 | $integrations = array(); |
| 110 | 110 | |
| 111 | 111 | if ( isset( $post_data['settings'] ) ) { |
| 112 | 112 | $settings = (array) json_decode( $post_data['settings'] ); |
| 113 | - $settings['message'] = sanitize_text_field( $settings['message'] ); | |
| 114 | - error_log(print_r($settings, true)); | |
| 115 | 113 | } else { |
| 116 | 114 | $settings = isset( $form_data['wpuf_settings'] ) ? $form_data['wpuf_settings'] : []; |
| 117 | 115 | } |
| 118 | 116 | |
| @@ -575,9 +573,9 @@ | ||
| 575 | 573 | } |
| 576 | 574 | } |
| 577 | 575 | } elseif ( empty( $field['value'] ) ) { |
| 578 | 576 | $has_empty = true; |
| 579 | - continue; | |
| 577 | + break; | |
| 580 | 578 | } else { |
| 581 | 579 | $field = WeForms_Form_Entry_Manager::format_entry_value( $field ); |
| 582 | 580 | array_push( $fields_formatted, $field ); |
| 583 | 581 | } |
| @@ -702,8 +700,9 @@ | ||
| 702 | 700 | * @return void |
| 703 | 701 | */ |
| 704 | 702 | public function handle_frontend_submission() { |
| 705 | 703 | check_ajax_referer( 'wpuf_form_add' ); |
| 704 | + | |
| 706 | 705 | $form_id = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : 0; |
| 707 | 706 | $page_id = isset( $_POST['page_id'] ) ? intval( $_POST['page_id'] ) : 0; |
| 708 | 707 | |
| 709 | 708 | $form = weforms()->form->get( $form_id ); |
| @@ -761,36 +760,28 @@ | ||
| 761 | 760 | $this->validate_submission( $entry_fields, $form, $form_settings, $form_fields ); |
| 762 | 761 | |
| 763 | 762 | $entry_fields = apply_filters( 'weforms_before_entry_submission', $entry_fields, $form, $form_settings, $form_fields ); |
| 764 | 763 | |
| 765 | - //check for entry_fields for a return error | |
| 766 | - if ( is_wp_error( $entry_fields ) ) { | |
| 767 | - wp_send_json( [ | |
| 768 | - 'success' => false, | |
| 769 | - 'error' => $entry_fields->get_error_message(), | |
| 770 | - ] ); | |
| 771 | - } else { | |
| 772 | - $entry_id = 1; | |
| 773 | - $global_settings = weforms_get_settings(); | |
| 774 | - if ( empty( $form_settings['after_submission'] ) ) { | |
| 775 | - $entry_id = weforms_insert_entry( [ | |
| 776 | - 'form_id' => $form_id, | |
| 777 | - ], $entry_fields ); | |
| 778 | - if ( is_wp_error( $entry_id ) ) { | |
| 779 | - wp_send_json( [ | |
| 780 | - 'success' => false, | |
| 781 | - 'error' => $entry_id->get_error_message(), | |
| 782 | - ] ); | |
| 783 | - } | |
| 784 | - // Fire a hook for integration | |
| 785 | - do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings ); | |
| 786 | - $notification = new WeForms_Notification( [ | |
| 787 | - 'form_id' => $form_id, | |
| 788 | - 'page_id' => $page_id, | |
| 789 | - 'entry_id' => $entry_id, | |
| 764 | + $entry_id = 1; | |
| 765 | + $global_settings = weforms_get_settings(); | |
| 766 | + if ( empty( $form_settings['after_submission'] ) ) { | |
| 767 | + $entry_id = weforms_insert_entry( [ | |
| 768 | + 'form_id' => $form_id, | |
| 769 | + ], $entry_fields ); | |
| 770 | + if ( is_wp_error( $entry_id ) ) { | |
| 771 | + wp_send_json( [ | |
| 772 | + 'success' => false, | |
| 773 | + 'error' => $entry_id->get_error_message(), | |
| 790 | 774 | ] ); |
| 791 | - $notification->send_notifications(); | |
| 792 | 775 | } |
| 776 | + // Fire a hook for integration | |
| 777 | + do_action( 'weforms_entry_submission', $entry_id, $form_id, $page_id, $form_settings ); | |
| 778 | + $notification = new WeForms_Notification( [ | |
| 779 | + 'form_id' => $form_id, | |
| 780 | + 'page_id' => $page_id, | |
| 781 | + 'entry_id' => $entry_id, | |
| 782 | + ] ); | |
| 783 | + $notification->send_notifications(); | |
| 793 | 784 | } |
| 794 | 785 | // redirect URL |
| 795 | 786 | $show_message = false; |
| 796 | 787 | $redirect_to = false; |
| @@ -825,9 +816,8 @@ | ||
| 825 | 816 | 'form_id' => $form_id, |
| 826 | 817 | 'entry_id' => $entry_id, |
| 827 | 818 | 'entry_fields' =>$entry_fields, |
| 828 | 819 | ] ); |
| 829 | - | |
| 830 | 820 | weforms_clear_buffer(); |
| 831 | 821 | wp_send_json( $response ); |
| 832 | 822 | } |
| 833 | 823 | |