Hello @pemptus !
Hope you’re doing well today!
It looks like that’s the case and it’s not an option available yet out of the box. I did however ask our Second Line Support team if they could create a small snippet to change that. We’ll update you here as soon as we hear back from them.
Best regards,
Pawel
Hello @pemptus !
Hope you’re doing well today!
Please try the following snippet:
<?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 = 361;//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;
}
}
To install:
– copy the code to a .php file
– adjust this line to match your form’s ID:
private $form_id = 361;//enter form_id here
– add a hidden field to the form
– adjust this line to provide the hidden field’s ID:
$entry_meta = array(
array(
'name' => 'hidden-1', // adjust here
'value' => $this->entry_id
)
);
– create wp-content/mu-plugins folder if it doesn’t exist
– upload the .php file to wp-content/mu-plugins
Best regards,
Pawel
I’ll check it out, thanks.
Alright, I’ve double-checked the snippet with two separate forms and it just doesn’t seem to work – the designated hidden field just returns whatever it’s set to return.
Could you take another look?
Hi @pemptus
I hope you are doing well.
I can see it will update to the database after Forminator submit it so ID wouldn’t show in the Email but it works fine on Submission:
https://monosnap.com/file/3jh6YkM45iSUmwJNwCin274iNalNfK
Can you double check?
Best Regards
Patrick Freitas
Hello @pemptus ,
We haven’t heard from you for a while now, so it looks like you don’t have more questions for us.
Feel free to re-open this ticket if needed.
Kind regards
Kasia
Hey,
I just found the time to check it again and it worked this time – not sure what I did differently, really. Might’ve been my error.
Thanks again, file this one under “definitely resolved”.