Description

The wpforms_display_field_before action fires before the form are displayed to determine the position of certain form elements such as labels.

Parameters

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

Source

wpforms/src/Frontend/Frontend.php

More Information

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.

Examples

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 );

Reference Articles