Autocomplete tag in form settings does not work anymore (as today Contact Form 7 plugin version 5.1.3
.
The only solution which worked for me was to add custom attributes thanks to https://stackoverflow.com/a/46316728/1720476.
E.g. if You have FirstName
and LastName
fields, where You want to disable autocomplete.
Add this into functions.php
file:
add_filter( 'wpcf7_form_elements', 'imp_wpcf7_form_elements' );
function imp_wpcf7_form_elements( $content ) {
$str_pos = strpos( $content, 'name="FirstName"' );
if ($str_pos) {
$content = substr_replace( $content, ' autocomplete="both" autocomplete="off" ', $str_pos, 0 );
}
$str_pos = strpos( $content, 'name="LastName"' );
if ($str_pos) {
$content = substr_replace( $content, ' autocomplete="both" autocomplete="off" ', $str_pos, 0 );
}
return $content;
}