Title: michaelbruch's Replies | WordPress.org

---

# michaelbruch

  [  ](https://wordpress.org/support/users/michaelbruch/)

 *   [Profile](https://wordpress.org/support/users/michaelbruch/)
 *   [Topics Started](https://wordpress.org/support/users/michaelbruch/topics/)
 *   [Replies Created](https://wordpress.org/support/users/michaelbruch/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/michaelbruch/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/michaelbruch/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/michaelbruch/engagements/)
 *   [Favorites](https://wordpress.org/support/users/michaelbruch/favorites/)

 Search replies:

## Forum Replies Created

Viewing 12 replies - 1 through 12 (of 12 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/page/2/#post-17740283)
 * Hello Adam, many thanks for adjusting the code.
 * The fix works wonderfully.
 * Best regards to the entire team.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/page/2/#post-17735158)
 * Hello Nithin, 
   yes, I have adjusted and expanded the code from the MU plugin 
   to include hidden-5. I don’t think that should be the problem. When I use your
   original code without the hidden-5 extension, it also doesn’t work.
 * I have incorporated the hidden-6 field as a test with the href URL, and hidden-
   7 is the non-functioning submission ID.
 * I could access the form backup and the MU plugin PHP on my SharePoint:
   [WPMUDEV](https://ovag-my.sharepoint.com/:f:/g/personal/bruch_ovag_de/EpQKPt6-3HdIlpyGu8BFF2IBR3N4oMHbne06yCtzycVY2w?e=o9b9CZ)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/page/2/#post-17721497)
 * Hello Adam,
 * `a) only happening if MU plugin is active and does not if it’s not activated?
   Or is it happening always? (I’m sorry if I’m asking the obvious but it’s not 
   quite clear to me based on your post)`
 * Yes, it only happens if the MU plugin is active and does not occur if it’s not
   activated.
 * `b) is it only happening in data exported (via integration) to Google Sheet or
   it’s also in e-mail notification and/or form submission on “Forminator -> Submissions”
   page?`
 * In the data export via integration to Google Sheets, I haven’t tested it. It’s
   not being used. We export via manual export to CSV. It works in email notifications
   via the shortcode. It doesn’t work in a hidden field in the form and therefore
   is not exported as a record in the CSV file.
 * Other data in hidden fields such as IP address, user agent, form URL work without
   issues. Only the submission ID doesn’t.
 * Here’s a screenshot of how it looks in the Submissions Backend. Shortened and
   censored:
 * > [View post on imgur.com](https://imgur.com/sxMQunR)
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/page/2/#post-17720241)
 * Hello Laura, thank you very much for your response. I know all of that. In the
   hidden field, I have also selected the Submission ID. It works even when the 
   mu_plugin from this forum thread is **not **activated.
 * The mu-plugin fills hidden-1 to 4. However, I have selected the Submission ID
   in hidden 5, but it doesn’t work when the mu-plugin is activated.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 3 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/page/2/#post-17712611)
 * Hello Nithin, thank you very much for your help.
 * The code works so far. Unfortunately, it causes an error with another hidden 
   field. Is it possible to use another hidden field outside of hidden-1 to hidden-
   4?
 * I need the hidden-5/or 6/or 7 field for the entry ID. I need this ID in the CSV
   table. In the CSV, I only get the following value returned and not the ID:
 * `Hidden: submission_id `
 * The correct ID is displayed in the user’s email with the shortcode {submission_id},
   and the ID is also shown in the subject of the email, just not in the CSV. When
   I deactivate the plugin, the ID works in the CSV.
 * This is the table from the database. The value from entry_id should also be in
   meta_value:
 * > [View post on imgur.com](https://imgur.com/BotEr7w)
 * ![](https://wordpress.org/5224089a-d968-4a3c-b709-f919d36328be)
    -  This reply was modified 2 years, 3 months ago by [michaelbruch](https://wordpress.org/support/users/michaelbruch/).
      Reason: add Image
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/#post-17484463)
 * Thank you very much for the code. It works great!
 * I have two more question:
    1. Is it possible to apply this code simultaneously to multiple forms? The form
       is duplicated every month, customized, and then published on the website according
       to a schedule. In my workflow, when duplicating and customizing, I can always
       add the new form ID. Or even globally for all forms? Then I wouldn’t need to
       adjust it ever.
    2. Would it also be possible to integrate a second different dropdown list where
       additional data is queried and built into other hidden fields?
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 5 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/#post-17475419)
 * Hello everyone, I’m sorry that I have to bring up the topic again.
 * Due to other projects, I had to pause this one initially. Now I’ve tried the 
   code again, and this time I didn’t encounter any error message. That was obviously
   a beginner’s mistake.
 * However, unfortunately, the desired result is still not implemented in the form.
   I have entered two sample data in the code and adjusted the form ID. In the form,
   I have created 4 hidden fields. The IDs of the fields match those in the code.
   Is it correct that I have to create the hidden fields myself in the form? If 
   yes, I am unsure what default value needs to be set in the hidden field.
 * After submitting the form, the fields remain empty or, depending on the default
   value set, it is entered in the field.
 * Here is the code used:
 *     ```wp-block-code
       <?php 
   
       add_action('wp_footer', 'wpmudev_hidden_field_value_update', 9999);
       function wpmudev_hidden_field_value_update(){
       	global $post;
       	if ( is_a( $post, 'WP_Post' ) && !has_shortcode($post->post_content, 'forminator_form') ) {
       		return;
       	}
       	?>
           <script type="text/javascript">
       	jQuery(document).ready(function($){
       		setTimeout(function() {
       			$('.forminator-custom-form').trigger('after.load.forminator');
       		},100);
   
       		$(document).on('after.load.forminator', function(e, form_id) {
       			if ( e.target.id == 'forminator-module-1889' ) { //Form ID
                       var school_arr = {};
                       school_arr['Altenstadt'] = ['7853', 'Schillerstrasse 2', '75897', 'Musterstadt']; //Schule
                       school_arr['Nauheim'] = ['4582', 'Am Solgraben 8', '58785', 'Neueschule']; //Schule
                       $('#select-1 select').on('select2:select', function(e) { 
       					var select_val = $(e.currentTarget).val();
       					$('input[name="hidden-1"]').val(school_arr[select_val][0]);
                           $('input[name="hidden-2"]').val(school_arr[select_val][1]);
                           $('input[name="hidden-3"]').val(school_arr[select_val][2]);
                           $('input[name="hidden-4"]').val(school_arr[select_val][3]);
       				});
       			}
       		});
       	});
       	</script>
       	<?php
       }
   
       add_filter( 'forminator_prepared_data', 'wpmudev_update_hidden_field_val', 10, 2 );
       function wpmudev_update_hidden_field_val( $prepared_data, $module_object ){
           $form_ids = array(1889);
       	if ( !in_array( $module_object->id, $form_ids ) ) {
       		return $prepared_data;
       	}
   
           foreach ( $prepared_data as $key => $value ) {
               if ( strpos( $key, 'hidden-' ) !== false ) {
                   $prepared_data[$key] = sanitize_text_field( $_POST[$key] );
               }
           }
   
       	return $prepared_data;
       }
   
       add_action( 'forminator_custom_form_submit_before_set_fields', 'wpmudev_change_hidden_field_data', 10, 3 );
       function wpmudev_change_hidden_field_data( $entry, $module_id, $field_data_array ) {
           $form_ids = array(1889); //Form ID
       	if ( !in_array( $module_id, $form_ids ) ) {
       		return;
       	}
   
           foreach ( $field_data_array as $key => $value ) {
               if ( strpos( $value['name'], 'hidden-' ) !== false ) {
                   Forminator_CForm_Front_Action::$info['field_data_array'][$key]['value'] = sanitize_text_field( $_POST[$value['name']] );
               }
           }
   
       }
       ```
   
 * Here is my form exported:
 * [https://hastebin.com/share/minuxunupe.swift](https://hastebin.com/share/minuxunupe.swift)
 * Thank you.
 * Best greetings.
    -  This reply was modified 2 years, 5 months ago by [michaelbruch](https://wordpress.org/support/users/michaelbruch/).
    -  This reply was modified 2 years, 5 months ago by [michaelbruch](https://wordpress.org/support/users/michaelbruch/).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/#post-17133586)
 * Hello Kasia, thank you very much for your help. I’ve adjusted and integrated 
   the code.
 * Unfortunately, I’m encountering an error on the front end of the website that
   says, “There was a critical error on your website.”
 * Do I need to replace just the “6” in the form ID “forminator-module-6” or the
   entire value? Similarly, there is a form ID in “add_filter section”
 *     ```wp-block-code
       $form_ids = array(6);
       ```
   
 * present, but there is no comment following it.
 * I have tested all variations with the form ID, but I keep getting the same error.
   For a test, I have only entered two schools. Or do all the selection fields need
   to be filled in?
 * Best regards, Michael.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/#post-17102617)
 * Hello Nithin, thank you for the quick response.
 * This was just an example.
 * In practice, there are currently 28 schools in a dropdown menu. More may be added
   in the future. There should be 4 hidden data fields for each: school number, 
   street, postal code, and city.
 * I believe this makes it a bit more complicated now. I chose a simple example 
   to initially explain it more straightforwardly.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Forminator Forms – Contact Form, Payment Form & Custom Form Builder] Automatically filled hidden fields](https://wordpress.org/support/topic/automatically-filled-hidden-fields/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/automatically-filled-hidden-fields/#post-17101865)
 * Hello, thank you for asking, yes – I hope you are too.
 * Yes, exactly like that. Additionally, the hidden fields should also appear in
   the CSV export.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Foyer - Digital Signage for WordPress] No Thumbnails in the Backend](https://wordpress.org/support/topic/no-thumbnails-in-the-backend/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/no-thumbnails-in-the-backend/#post-12459508)
 * Hello Menno and thank you very much.
 * Exactly for that reason it didn’t work. I had update the adress to https in WordPress
   and now it’s working fine. Thank you for your help.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Foyer - Digital Signage for WordPress] No Thumbnails in the Backend](https://wordpress.org/support/topic/no-thumbnails-in-the-backend/)
 *  Thread Starter [michaelbruch](https://wordpress.org/support/users/michaelbruch/)
 * (@michaelbruch)
 * [6 years, 6 months ago](https://wordpress.org/support/topic/no-thumbnails-in-the-backend/#post-12376434)
 * [@clubeddie](https://wordpress.org/support/users/clubeddie/)
    Thank you. But 
   it’s not working. I test also some other regenerate plugins.
    -  This reply was modified 6 years, 6 months ago by [michaelbruch](https://wordpress.org/support/users/michaelbruch/).

Viewing 12 replies - 1 through 12 (of 12 total)