Detects the form and submission from the request.
Description
See also
Parameters
- $data
-
(array) (Required) Submission POST data.
Return
(array|WP_Error) Array with 'form' and 'submission' keys, or error object on failure.
Source
File: src/db-objects/forms/form-frontend-submission-handler.php
protected function detect_request_form_and_submission( $data ) { $form = null; $submission = null; if ( ! empty( $data['id'] ) ) { $submission = $this->form_manager->get_child_manager( 'submissions' )->get( absint( $data['id'] ) ); if ( $submission ) { if ( 'completed' === $submission->status ) { return new WP_Error( 'submission_already_completed', __( 'Submission already completed.', 'torro-forms' ) ); } if ( ! empty( $submission->form_id ) ) { $form = $submission->get_form(); } } } if ( ! $form ) { if ( empty( $data['form_id'] ) ) { return new WP_Error( 'cannot_detect_form', __( 'Could not detect form.', 'torro-forms' ) ); } $form = $this->form_manager->get( absint( $data['form_id'] ) ); if ( ! $form ) { return new WP_Error( 'cannot_detect_form', __( 'Could not detect form.', 'torro-forms' ) ); } } return array( 'form' => $form, 'submission' => $submission, ); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |