1

I have below code for contact form 7. Usually I use autocomplete="off" for html input field. However not able to figure out how to do the same for contact form 7

<div class="row">
<div class="col-md-6">
    [text* FirstName placeholder "First Name"]
</div>
<div class="col-md-6">
    [text* LastName placeholder "Last Name"]
</div>
<div class="col-md-12">
    [email* EmailAddress placeholder "Email Address"]
</div>
<div class="col-md-12">
    [text* desc placeholder "Tell us a bit about yourself..."]
</div>
<div class="col-md-12">
    [submit "Submit"]
</div>
</div>
1

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"' );
    $content = substr_replace( $content, ' autocomplete="both" autocomplete="off" ', $str_pos, 0 );

    $str_pos = strpos( $content, 'name="LastName"' );
    $content = substr_replace( $content, ' autocomplete="both" autocomplete="off" ', $str_pos, 0 );

    return $content;
}
  • Cool. Thank you for posting answer for updated version. – Varsha Dhadge Jul 10 at 7:59
5

According to the question and answer from the developer placed here: https://wordpress.org/support/topic/autocomplete-off-3/

You just need to add the autocomplete:off option to the shortcode:

[email your-email autocomplete:off "example@example.com"]

Though if the plugin has not been updated as stated in that question to use autocomplete:false Chrome may ignore it still. If it doesn't work yet you may need to raise support with the plugin author. Autocomplete was added to this plugin in version 4.5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.