### [wpforms_frontend_output_before](https://wpforms.com/developers/wpforms_frontend_output_before/)

**Published:** February 17, 2020
**Author:** Editorial Team

**Excerpt:** The wpforms_frontend_output_before action fires before a form is displayed on the site's frontend, only if the form exists and contains fields.


**Content:**

## Description

The `wpforms_frontend_output_before` action fires before a form is displayed on the site’s front end, 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/src/Frontend/Frontend.php`

## More Information

While `wpforms_frontend_output_before` only fires for valid non-empty forms, it executes early on in the output rendering process.

In some cases, the action may fire but the form will not display, such as displaying a form confirmation message or triggering the `wpforms_frontend_load` filter.

An alternate action to consider is [wpforms\_frontend\_output\_after](https://wpforms.com/developers/wpforms_frontend_output_after/ "The wpforms_frontend_output_after action"), as it functions similarly, except only fires **after** the form is displayed.

## Examples

In our example code snippet, you’ll see below, we are going to be checking first to see if the form ID is equal to **5**. If it is, we’ll echo out a link to download the digital catalog.

Just remember to change the form ID from `5` to match the specific form ID you’re wanting to run your code on. Removing that check would run for all forms.

```

/**
 * Output something before your form(s).
 * 
 * @link  https://wpforms.com/developers/wpforms_frontend_output_before/
 *
 * @param array  $form_data Form data and settings.
 * @param object $form      Form post type object.
 */

function wpf_dev_frontend_output_before( $form_data, $form ) {
    
    // Optional, you can limit to specific forms. Below, we restrict output to
    // form #5.
    if ( absint( $form_data[ 'id' ] ) !== 5 ) {
        return;
    } 

    // Run code or see the example echo statement below.
    _e( 'If you would like to download our digital catalog, click here.', 'plugin-domain' );

}

add_action( 'wpforms_frontend_output_before', 'wpf_dev_frontend_output_before', 10, 2 );
```

## Reference Articles

[How to Add a Video Before Your Form](https://wpforms.com/developers/how-to-add-a-video-before-your-form/ "How to Add a Video Before Your Form")

**Categories:** Actions Hooks

**Tags:** PHP

---

