Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable autocomplete on the front-end for Gravity Forms
<?php
add_filter( 'gform_form_tag', 'gform_form_tag_autocomplete', 11, 2 );
function gform_form_tag_autocomplete( $form_tag, $form ) {
if ( is_admin() ) return $form_tag;
if ( GFFormsModel::is_html5_enabled() ) {
$form_tag = str_replace( '>', ' autocomplete="off">', $form_tag );
}
return $form_tag;
}
add_filter( 'gform_field_content', 'gform_form_input_autocomplete', 11, 5 );
function gform_form_input_autocomplete( $input, $field, $value, $lead_id, $form_id ) {
if ( is_admin() ) return $input;
if ( GFFormsModel::is_html5_enabled() ) {
$input = preg_replace( '/<(input|textarea)/', '<${1} autocomplete="off" ', $input );
}
return $input;
}
?>
@helpfulnerd

This comment has been minimized.

Copy link

commented Jun 21, 2014

What file do I add that code to? Or do I create a new php file and where do I put it? Thanks.

@JayHoltslander

This comment has been minimized.

Copy link

commented Aug 30, 2017

Doesn't work in Safari. Form inputs still autocomplete/autofill.

@adamthomson

This comment has been minimized.

Copy link

commented Jan 30, 2019

This doesn't appear to be working any more. Additionally the HTML5 checkbox you mentioned on your blog is no longer there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.