post_id in hook rwmb_frontend_after_process is missing

Support MB Frontend Submission post_id in hook rwmb_frontend_after_process is missing

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #8428
    flowdeeflowdee
    Participant

    Planning to use the hook "rwmb_frontend_after_process" in order to redirect the user directly to the newly submitted post.

    Unfortunately "post_id" is set to 0 in the $config variable, passed by the hook.

    [01-Feb-2018 11:09:38 UTC] Array
    (
        [id] => board_submission
        [post_type] => board
        [post_id] => 0
        [post_status] => publish
        [post_fields] => title,excerpt,content
        [submit_button] => Submit Topic
        [confirmation] => Your post has been successfully submitted. Thank you.
    )
    #8434
    Anh TranAnh Tran
    Keymaster

    Hello, I've just added submitted post ID to the $config variable. Please update the plugin.

    #9263
    ingegnimultimedialiingegnimultimediali
    Participant

    Hi,
    I'm trying to redirect (after submission) to a thank you page with newly submitted post attached to query string but
    "post_id" is always = 0


    this is my code

    add_action( 'rwmb_frontend_after_process', function( $config ) {
        if ( 'nuovo-ordine' === $config['id'] ) {
            wp_safe_redirect( '?rwmb-form-submitted=nuovo-ordine&post_id='.$config["post_id"] );
            die;
        }
    } );
    #9269
    Anh TranAnh Tran
    Keymaster

    Somehow I removed the post id. I've just added in the version 1.3.3, please update the plugin and use the code below:

    add_action( 'rwmb_frontend_after_process', function( $config, $post_id ) {
        if ( 'nuovo-ordine' === $config['id'] ) {
            wp_safe_redirect( '?rwmb-form-submitted=nuovo-ordine&post_id='.$post_id );
            die;
        }
    }, 10, 2 );

    I added the 2nd parameter $post_id to the hook. Please try and let me know how it works.

    #9272
    ingegnimultimedialiingegnimultimediali
    Participant

    Now it works fine!
    Thnks

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘post_id in hook rwmb_frontend_after_process is missing’ is closed to new replies.