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_display_field_before action fires before the form are displayed to determine the position of certain form elements such as labels.

Parâmetros

$fields
(array) Sanitized entry field values/properties.
$form_data
(array) Form settings/data.

Fonte

wpforms/src/Frontend/Frontend.php

Mais Informações

The action fires before the form is displayed. This action can be used to move attributes of the form around such as form field labels.

Exemplos

In this example, we’re going to remove the labels completely by removing the action.

/**
 * Action fires before the form is displayed to determine the position of certain form elements such as labels.
 *
 * @link   https://wpforms.com/developers/wpforms_display_field_before/
 * 
 * @param  array    $fields      Sanitized entry field values/properties.
 * @param  array    $form_data   Form settings/data.
 * @return array
 */


function wpf_dev_display_field_before( $field, $form_data ) {
  
    // Only run this snippet on the form with the ID of 879
    if ( absint( $form_data[ 'id' ] ) !== 879 ) {
        return;
    }
 
    remove_action( 'wpforms_display_field_before', array( wpforms()->frontend, 'field_label' ), 15, 2 );
}
add_action( 'wpforms_display_field_before', 'wpf_dev_display_field_before', 10, 2 );

Artigos de Referência