Adding autocomplete attributes | WordPress.org

[ad_1]

Hey @treylok

This can be achieved with a custom snippet for the time being until we add this feature.

Place this snippet in your child theme’s functions.php file and modify the IDs accordingly.

add_filter('mf_field_display_args', 'mf_custom_field_display_attributes', 10, 1);
function mf_custom_field_display_attributes($params) {

$traget_form_id = 80;
if ( strpos($params['id'], "mform_{$traget_form_id}_mfield_") !== 0 ) {
return $params;
}

$prefix = "mform_{$traget_form_id}_mfield_";
$firstname_field_id = 1;
$lastname_field_id = 2;
$email_field_id = 3;
switch ($params['id']) {
case "{$prefix}{$firstname_field_id}":
$params['attributes']['autocomplete'] = 'given-name';
break;
case "{$prefix}{$lastname_field_id}":
$params['attributes']['autocomplete'] = 'family-name';
break;
case "{$prefix}{$email_field_id}":
$params['attributes']['autocomplete'] = 'off';
break;
default:
break;
}

return $params;
}

Let me know if you have any additional questions.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer