• Resolved lindagester

    (@lindagester)


    Hi,
    I need a function that disables all browers from autocomplete the input fields in my registration form. I don’t want to edit the plugin php-files. Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @lindagester,

    You can disable autocomplete to all fields by adding the following code in your theme’s function.php file.

    function user_registration_add_auto_complete( $args, $key, $value ) {
        switch ( $key ) {
    	default:
    	    $args['custom_attributes']['autocomplete'] = 'off';
    	    break;
        }
        return $args;
    }
    add_filter( 'user_registration_form_field_args', 'user_registration_add_auto_complete', 10, 3 );

    However, if you want to disable for selective fields you can add their key in “case” of switch condition. Key is the field name in your field option of the field in the form builder

    function user_registration_add_auto_complete( $args, $key, $value ) {
        switch ( $key ) {
            case 'user_email':
    	case 'user_pass':
                $args['custom_attributes']['autocomplete'] = 'off';
    	    break;
        }
        return $args;
    }
    add_filter( 'user_registration_form_field_args', 'user_registration_add_auto_complete', 10, 3 );

    Thanks & Regards!

    • This reply was modified 5 years, 10 months ago by Rumesh Udash.
    • This reply was modified 5 years, 10 months ago by Rumesh Udash.
    Thread Starter lindagester

    (@lindagester)

    Thanks, looks great! But unfortunately it doesn’t work. Chrome still tries to autofill the email and password field. I’ve cleared the cache but nothing happens.

    • This reply was modified 5 years, 10 months ago by lindagester.

    Hi @lindagester,

    I think you are referring to is Saved Password. It’s not autofill. Sorry, but it’s beyond our control.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Disable autocomplete’ is closed to new replies.