Resumo de IA
Descrição
The wpforms_frontend_form_atts filter fires on form load to display the form frontend attributes.
Parâmetros
- $atts
- (array) An array of form attributes.
- $form_data
- (array) Configurações/dados do formulário processados, preparados para uso posterior.
Fonte
wpforms/src/Frontend/Frontend.php
Mais Informações
The filter is applied to an array for specific form attributes.
Exemplos
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.