groundhogg/form/v2/submit

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Action Hooks

Β»

groundhogg/form/v2/submit

Fires after a v2 Groundhogg form is successfully submitted, the contact record has been created or updated, and all post-submission processing is complete.

do_action( 'groundhogg/form/v2/submit', $submission, $form, $contact );

You will receive the Submission object, the Form_v2 object, and the Contact object as arguments.

Example

add_action( 'groundhogg/form/v2/submit', 'my_extension_on_form_submit', 10, 3 );

/**
 * Forward form answers to an external service on submission.
 *
 * @param \Groundhogg\Submission $submission
 * @param \Groundhogg\Form_v2    $form
 * @param \Groundhogg\Contact    $contact
 *
 * @return void
 */
function my_extension_on_form_submit( $submission, $form, $contact ) {
    if ( $submission->get_form_id() !== MY_EXTENSION_TARGET_FORM_ID ) {
        return;
    }

    wp_remote_post( MY_EXTENSION_WEBHOOK_URL, [
        'body' => array_merge( $submission->get_answers(), [
            'contact_email' => $contact->get_email(),
        ] ),
    ] );
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.