PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.4.2
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.4.2
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
← All changes | inc/background-process.php +5 -44 2.8.21.4.2 View file →
@@ -91,24 +91,13 @@
91 91 * @since 0.0.3
92 92 * @return \WP_REST_Response|\WP_Error Response object on success, or WP_Error object on failure.
93 93 */
94 94 public function handle_after_submission( $request ) {
95 - $this->submission_id = Helper::get_integer_value( $request->get_param( 'submission_id' ) );
96 95
97 - $extras = $this->get_extras_data( $this->submission_id );
98 - $is_after_submission_process_triggered = $extras['is_after_submission_process_triggered'] ?? false;
96 + $nonce = Helper::get_string_value( $request->get_header( 'X-WP-Nonce' ) );
99 97
100 - if ( $is_after_submission_process_triggered ) {
98 + if ( ! wp_verify_nonce( sanitize_text_field( $nonce ), 'wp_rest' ) ) {
101 99 return new \WP_Error(
102 - 'process_already_triggered',
103 - __( 'After submission process has already been triggered for this submission.', 'sureforms' ),
104 - [ 'status' => 403 ]
105 - );
106 - }
107 -
108 - $nonce = Helper::get_string_value( $request->get_param( 'after_submit_nonce' ) );
109 - if ( ! wp_verify_nonce( sanitize_text_field( $nonce ), 'srfm_after_submission_' . Helper::get_string_value( $this->submission_id ) ) ) {
110 - return new \WP_Error(
111 100 'rest_nonce_failed',
112 101 __( 'Nonce verification failed.', 'sureforms' ),
113 102 [ 'status' => 403 ]
114 103 );
@@ -113,8 +102,10 @@
113 102 [ 'status' => 403 ]
114 103 );
115 104 }
116 105
106 + $this->submission_id = Helper::get_integer_value( $request->get_param( 'submission_id' ) );
107 +
117 108 if ( ! ( 0 < $this->submission_id ) ) {
118 109 return new \WP_Error(
119 110 'incomplete_request',
120 111 __( 'Submission id missing.', 'sureforms' ),
@@ -129,9 +120,9 @@
129 120
130 121 if ( ! $this->trigger_after_submission_process() ) {
131 122 return new \WP_Error(
132 123 'process_failed',
133 - __( 'Something went wrong. We have logged the error for further investigation', 'sureforms' ),
124 + __( 'Something went wrong. We haved logged the error for further investigation', 'sureforms' ),
134 125 [ 'status' => 403 ]
135 126 );
136 127 }
137 128
@@ -156,37 +147,7 @@
156 147 *
157 148 * @param array $form_data form data related to submission.
158 149 */
159 150 do_action( 'srfm_after_submission_process', $form_data );
160 -
161 - // Update the extras column to track that the after submission process was triggered.
162 - if ( 0 < $this->submission_id ) {
163 - $extras = $this->get_extras_data( $this->submission_id );
164 -
165 - // Merge new data.
166 - $updated_extras = array_merge(
167 - $extras,
168 - [ 'is_after_submission_process_triggered' => true ]
169 - );
170 -
171 - // Update entry.
172 - Entries::update(
173 - $this->submission_id,
174 - [ 'extras' => $updated_extras ]
175 - );
176 - }
177 -
178 151 return true;
179 - }
180 -
181 - /**
182 - * Get extras data from entry.
183 - *
184 - * @param int $submission_id Submission ID.
185 - * @since 1.13.2
186 - * @return array<string|int,mixed> Extras array.
187 - */
188 - protected function get_extras_data( $submission_id ) {
189 - $entry_data = Entries::get( $submission_id );
190 - return Helper::get_array_value( $entry_data['extras'] ) ?? [];
191 152 }
192 153 }