Atenção!

Este artigo contém código PHP e destina-se a desenvolvedores. Oferecemos este código como uma cortesia, mas não fornecemos suporte para personalizações de código ou desenvolvimento de terceiros.

Para orientação extra, consulte o tutorial do WPBeginner sobre como adicionar código personalizado.

Dispensar

Descrição

The wpforms_frontend_output_after action fires after a form is displayed on the site’s front end, only if the form exists and contains fields.

Parâmetros

$form_data
(array) Configurações/dados do formulário processados, preparados para uso posterior.
$form
(WP_Post) Form post type object.

Fonte

wpforms/src/Frontend/Frontend.php

Mais Informações

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.

Exemplos

An example to use this particular action may be to display a link just after the Submit button on the form.

Just remember to change the form ID from 731 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.

If you need help in finding your form ID, please review this tutorial.

/**
 * Output something after your form(s).
 *
 * @link  https://wpforms.com/developers/wpforms_frontend_output_after/
 *
 * @param array  $form_data Form data and settings.
 * @param object $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 #731.
    if ( absint( $form_data[ 'id' ] ) !== 731 ) {
        return;
    } 

    // Run code or see the example echo statement below.
    _e( 'Click here for our Black Friday Offers!  <a href="http://yourlinkurl.com/black-friday" target="_blank">Check out our Black Friday deals!</a>.', 'plugin-domain' );

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

Artigos de Referência