Forked from wpmudev-sls/forminator-add-autocomplete-attr.php
Created
December 9, 2020 08:53
-
-
Save valerionew/19ea1f8f85fe1a35f174313b8294f9c5 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Add "autcomplete" attribute to input fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
It does