• Resolved Pemptus

    (@pemptus)


    Hi,
    I’m playing around with the save as draft option and I’m missing one thing: the ability to edit the drafts from the control panel, or to recover the link somehow.
    It seems that there’s no way to recover the “continue” link if you skip the “copy this link or put in your email” step, even as the same user that was filling in the form.

    We want to use the form as a sort of checklist and then come back to it after 100+ days as a sort of “unchecklist”. The way it works right now is a bit cumbersome.

    Possible workaround: ability to copy the draft link to a hidden field, maybe? Would that be possible?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    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

    Thread Starter Pemptus

    (@pemptus)

    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.

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    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

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    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

    Thread Starter Pemptus

    (@pemptus)

    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?

    Plugin Support Nebu John – WPMU DEV Support

    (@wpmudevsupport14)

    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

    Thread Starter Pemptus

    (@pemptus)

    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.

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    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

    Thread Starter Pemptus

    (@pemptus)

    By all means, mark away.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Edit drafts from admin panel, copy draft link’ is closed to new replies.