• Resolved shagdirty

    (@shagdirty)


    Howdy. I’d like to pass the submission id (sub_id) as a variable (GET or however) to the form redirect page so that I can manipulate the entry after the fact. Any idea on how I can accomplish that? Tried several things from the docs but not having much luck.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter shagdirty

    (@shagdirty)

    Actually figured it out using cookies…

    Added this to my themes custom js file…

    var mySubmitController = Marionette.Object.extend( {  
      initialize: function() {
        this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit );
      },
    
      actionSubmit: function( response ) {
        // delete any old subid cookies... (probably not necessary since we're (re)setting it below but whatever)   
        document.cookie = 'subid=;expires=Thu, 01 Jan 1970 00:00:01 GMT;';
        var subID = response.data.actions.save.sub_id;
        // just to make sure we're getting the correct sub_id...
        console.log('SUB ID: ' + subID); 
        // you can see all the data for this form submission...
        console.log(response);
        // set a cookie to hold the sub_id...
        document.cookie = 'subid=' + subID + '; expires=Thu, 31 Dec 2030 12:00:00 UTC; path=/';
      },
    });
    
    jQuery( document ).ready( function( $ ) {
        // Instantiate our custom field's controller, defined above.
        new mySubmitController();
    });

    At this point you should have a cookie ‘subid’ with a value of the submission id. You can do with that whatever you need. I’m getting/displaying mine on the redirect page with php:

    $sub_id = $_COOKIE['subid'];
    echo 'sub_id: ' . $sub_id;

    There may be a more reliable and efficient way to do this but this works for my purposes.

    • This reply was modified 6 years ago by shagdirty.
Viewing 1 replies (of 1 total)
  • The topic ‘Passing Submission ID to redirect page’ is closed to new replies.