Hi @pemptus
I hope you’re well today!
You are right – currently there’s no “edit” option for editing submissions (neither “drafts” nor complete submissions). This is something that’s already on a list of features planned for future but at the moment it’s not yet possible and I don’t have an ETA, I’m afraid.
As for recovering draft link – it’s not “a click away” but it is actually possible because a “draft ID” is saved with each draft.
So let’s say that your form is on page
https://domain.com/form-page/
Once the draft is saved you can check draft ID by viewing this draft submission on “Forminator -> Submissions” page.
Then you just need to enter URL like this
https://domain.com/form-page/?draft=XXX
where XXX would be replaced with that draft ID taken from saved submission.
So while as of now there’s no a “click solution” you can still create such draft link manually to share it with user.
Best regards,
Adam
I see, thanks. I guess that’ll have to do for now.
I don’t suppose there’s a variable that can be used for a hidden field? Similar to “Submission ID” from the preset, but “Draft ID”? That would make it a bit more convenient and open up some possibilities.
Hi @pemptus,
I am afraid draft ID is unavailable as a default variable in the Hidden field. I have brought this to the notice of our developers to check if we can provide a quick workaround for this.
Kind Regards,
Nebu John
Hi @pemptus,
Please try the following workaround on your staging/test website, it should help.
add_filter( 'forminator_form_save_draft_response', 'wpmudev_update_draft_id_hidden', 10, 2 );
function wpmudev_update_draft_id_hidden( $response, $form_id ) {
if( $form_id != 361 ) { //Please change the form ID here
return $response;
}
$draft_id = isset( $response['draft_id'] ) ? $response['draft_id'] : '';
if ( $draft_id ) {
global $wpdb;
$entry_table_name = Forminator_Database_Tables::get_table_name( Forminator_Database_Tables::FORM_ENTRY );
$sql = "SELECT <code>entry_id</code> FROM {$entry_table_name} WHERE <code>form_id</code> = %d AND <code>draft_id</code> = %s";
$entry_id = $wpdb->get_var( $wpdb->prepare( $sql, $form_id, $draft_id ) );
if ( $entry_id ) {
$entry_meta = array(
array(
'name' => 'hidden-1',
'value' => $draft_id
)
);
Forminator_API::update_form_entry( $form_id, $entry_id, $entry_meta );
}
}
return $response;
}
Please note, you need to change the form ID here if( $form_id != 361 ) { and the field ID hidden-1 it it is different. You can add the code using a mu-plugin. Please find more details here: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins
Kind Regards,
Nebu John
Thanks.
I checked it out and it doesn’t seem to do anything. I added the “<?php” opening tag, put the file in mu-plugins – as is tradition – and edited $form_id and hidden-1 as appropriate. The hidden field behaves as it always does.
I double-checked the form id, and folder permissions are ok as well.
Am I missing something? Should the hidden field be the “Query Parameter” or “Custom value” type? What should I enter there, if so?
Hi @pemptus,
Sorry, while sharing the snippet, this symbol(`) changed to <code>, that’s why it’s not working.
Can you please check if the following code works? I checked this on a test website and ensured it worked as expected.
add_filter( 'forminator_form_save_draft_response', 'wpmudev_update_draft_id_hidden', 10, 2 );
function wpmudev_update_draft_id_hidden( $response, $form_id ) {
if( $form_id != 361 ) { //Please change the form ID here
return $response;
}
$draft_id = isset( $response['draft_id'] ) ? $response['draft_id'] : '';
if ( $draft_id ) {
global $wpdb;
$entry_table_name = Forminator_Database_Tables::get_table_name( Forminator_Database_Tables::FORM_ENTRY );
$sql = "SELECT entry_id FROM {$entry_table_name} WHERE form_id = %d AND draft_id = %s";
$entry_id = $wpdb->get_var( $wpdb->prepare( $sql, $form_id, $draft_id ) );
if ( $entry_id ) {
$entry_meta = array(
array(
'name' => 'hidden-1',
'value' => $draft_id
)
);
Forminator_API::update_form_entry( $form_id, $entry_id, $entry_meta );
}
}
return $response;
}
The hidden field should be set to custom value. Please let us know how that goes.
Kind Regards,
Nebu John
Great, it works now.
Now I can just edit the ‘value’ in the script to put together a draft link – this will make things a bit more convenient.
Thanks for going the extra mile.
Hi @pemptus
I’m happy to hear it works for you now!
I suppose we can mark this ticket as resolved then, right?
Best regards,
Adam