Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wpmudev-sls/b7b3bc8d26ffa0b8533e69c15632e142 to your computer and use it in GitHub Desktop.
Save wpmudev-sls/b7b3bc8d26ffa0b8533e69c15632e142 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Add "autcomplete" attribute to input fields
<?php
/**
* Plugin Name: [Forminator Pro] - Add "autcomplete" attribute to input fields
* Plugin URI: https://premium.wpmudev.org/
* Description: Add "autcomplete" attribute support to selected form and input fields (as of 1.12.1.1)
* Author: Alessandro Kaounas @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* Task: 0/1135022585412927/1176249490871345
* License: GPLv2 or later
*/
add_action( 'forminator_before_form_render', function( $form_id ){
// Add form id to apply below
if( $form_id != '334' ){
return;
}
// Add fields you want to apply "autocomplete" attribute
add_filter( 'forminator_field_markup', function( $html, $field ){
$element = '<input';
if( $field['element_id'] == 'name-1' ){
if( strpos( $html, $element ) ){
$name = 'cc-name';
return str_replace( $element, $element . ' autocomplete="' . $name . '"', $html );
}
}
/**
* [...] add more if conditions here depending on your fields :)
*/
return $html;
}, 10, 2);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment