Description
The wpforms_frontend_form_atts
filter fires on form load to display the form frontend attributes.
Parameters
- $atts
- (array) An array of form attributes.
- $form_data
- (array) Processed form settings/data, prepared to be used later.
Source
wpforms/src/Frontend/Frontend.php
More Information
The filter is applied to an array for specific form attributes.
Examples
In this example shown below, the function will disable the browser autocomplete for the form ID 11. Just remember to change the form ID from 11 to match the specific form ID you’re wanting to run your code on.
Removing that check would run the code for all forms.
/** * Remove browser autocomplete. * * @link https://wpforms.com/developers/wpforms_frontend_form_atts/ * * @param array $atts Form attributes. * @param array $form_data Form data and settings. * * return array */ function wpf_dev_disable_form_autocomplete( $atts, $form_data ) { // This check will only form autocomplete for Form #11. // Removing this check would disable autocomplete on ALL forms. if ( absint( $form_data[ 'id' ] ) !== 11 ) { return $atts; } $atts[ 'atts' ][ 'autocomplete' ] = 'nope'; return $atts; } add_filter( 'wpforms_frontend_form_atts', 'wpf_dev_disable_form_autocomplete', 10, 2 );
If you need help in finding these IDs, please check out this tutorial.