Description

Action fires after a form is displayed on the site’s frontend, only if the form exists and contains fields.

Parameters

$form_data
(array) Processed form settings/data, prepared to be used later.
$form
(WP_Post) Form post type object.

Source

wpforms/includes/class-frontend.php

More Information

While wpforms_frontend_output_after only fires for valid non-empty forms, it executes after the output rendering process.

An alternate action to consider is wpforms_frontend_output_before, as it functions similarly, except only fires before the form is displayed.

Examples

An example to use this particular action may be to display a merchant verified badge from your payment gateway under the form. The example below would show our image (acme-verified.jpg) just after the submit button.

Just remember to change the form ID from 5 to match the specific form ID you’re wanting to run your code on as well as the images directory (if calling an image) to match that of your theme structure.

/**
 * Output something after your form(s).
 *
 * @link  https://wpforms.com/developers/wpforms_frontend_output_after/
 *
 * @param array  $form_data Form data and settings.
 * @param int    $form      Form post type object.
 */
function wpf_dev_frontend_output_after( $form_data, $form ) {
    
    // Optional, you can limit to specific forms. Below, we restrict output to
    // form #25.
    if ( absint( $form_data['id'] ) !== 25 ) {
        return;
    } 

    // Run code or see example echo statement below.
    echo '<img src="'.get_template_directory_uri().'/images/acme-verified.jpg" alt="Verified by ACME gateways" width="80" height="80">';

}
add_action( 'wpforms_frontend_output_after', 'wpf_dev_frontend_output_after', 10, 2 );