/** * Do not store the cached IP address in a hidden field * * @link https://wpforms.com/developers/how-to-store-the-non-cached-ip-address-into-a-hidden-field/ */ function wpf_hidden_ip_avoid_cache( $fields, $entry, $form_data ){ // Only run on the form with ID 100 if( $form_data[ 'id' ] == 100 ) { //Look for the hidden field we want to replace the value of foreach( $fields as $field_id => $field ){ // Look for field ID is 18 - it MUST be a Hidden Field, change this ID to match your field ID if( '18' == $field[ 'id' ] && 'hidden' == $field[ 'type' ] ){ // Replace that value with the IP WPForms detects $fields[ $field_id ][ 'value' ] = wpforms_get_ip(); } } } return $fields; } add_filter( 'wpforms_process_filter', 'wpf_hidden_ip_avoid_cache', 10, 3 );
Categories
Uncategorized

Hello world!

Welcome to WordPress. This is your first post. Edit or delete it, then start writing!

Leave a Reply

Your email address will not be published. Required fields are marked *