• Resolved Hhentsch

    (@hhentsch)


    hello
    i like to have the export to csv with the submission_id
    I can use/print out the submission_id btw in email but not in csv export
    please, can you solve this problem?
    thx

    • This topic was modified 1 year, 3 months ago by Hhentsch.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hi @hhentsch

    Hope you are doing fine.

    In order to add the submission id in the form, you’ll need to use custom code and also add a hidden field. This hidden field will store the submission id value and will be included as an additional column in the csv file.

    You’ll need to add a must-use plugin to your site’s wp-content/mu-plugins folder as explained in our documentation here: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins, then add the following code provided to the plugin’s php file:

    <?php
    
    add_action( 'plugins_loaded', 'wpmudev_forminator_add_entry_id_to_hidden_field_func', 100 );
    
    function wpmudev_forminator_add_entry_id_to_hidden_field_func() {
    	if ( class_exists( 'Forminator' ) ) {
    		class wpmudev_forminator_add_entry_id_to_hidden_field_func{
    			private $form_id = 327;//enter form_id here
    			private $entry_id;
    
    			public function __construct(){
    				add_action( 'forminator_custom_form_submit_before_set_fields', array( $this, 'retrive_entry_id' ), 10, 2 );
    				add_action( 'forminator_form_after_save_entry', array( $this, 'add_entry_id_to_hidden_field'), 10, 2);
    			}
    
    			public function retrive_entry_id( $entry, $form_id ){
    				if( $this->form_id == $form_id ){
    					$this->entry_id = $entry->entry_id;
    				}
    			}
    
    			public function add_entry_id_to_hidden_field( $form_id, $response ){
    				if( $this->form_id == $form_id ){
    					$entry_meta = array(
    						array(
    						'name' => 'hidden-1',
    						'value' => $this->entry_id
    						)
    					);
    					$entries = Forminator_API::get_entries( $form_id );
    					Forminator_API::update_form_entry( $form_id, $entries[0]->entry_id, $entry_meta );
    				}
    			}
    
    		}
    
    		$run = new wpmudev_forminator_add_entry_id_to_hidden_field_func;
    	}
    }

    – Adjust this line to match your form’s ID:

    private $form_id = 327;//enter form_id here

    – Add a hidden field to the form
    – Adjust this line to provide the hidden field’s name:

    $entry_meta = array(
        array(
            'name' => 'hidden-1', // adjust here
            'value' => $this->entry_id
        )
    );

    I ran a test on my lab site and got the following results:

    https://snipboard.io/0WvkHB.jpg

    When the CSV is exported, you can use the hidden field column to identify each of the submissions:

    https://snipboard.io/FK6ZaP.jpg

    Hope this information helps, feel free to reply if you have any additional questions.

    Kind regards

    Luis

    Thread Starter Hhentsch

    (@hhentsch)

    Hello Luis

    It’s a little cumbersome but the result counts. Thanks for the help

    Plugin Support Zafer – WPMU DEV Support

    (@wpmudevsupport15)

    Hi @hhentsch,

    We are happy to hear that the issue has been resolved and marking this thread accordingly.
    Please let us know in case you need further help.

    Kind regards,
    Zafer

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CSV Export with submission_id ?’ is closed to new replies.