Support » Plugin: Post My CF7 Form » Redirect to post

  • Resolved moacirsantana

    (@moacirsantana)


    Hello, I’ve seen there’s a tutorial to redirect to a specific page, how do I redirect to the post created right after the submission?

    Thank you

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi @moacirsantana, apologies for the late reply, I somehow missed this post.

    how do I redirect to the post created right after the submission?

    haha, that’s an excellent question.

    So you follow the same logic as the redirection to a page (FAQ #1), and in the redirected page template you use the [wp_redirect()](https://developer.wordpress.org/reference/functions/wp_redirect/) function to redirect to your saved post, assuming you have published the post automatically (by default it isn’st, see FAQ #16),

    
    //from FAQ #1...
    if(isset($_GET['cf72post'])){
      $post_id = get_transient($_GET['cf72post']);
      //get the link to the new post,
      $url = get_permalink($post_id);
      if ( wp_redirect( $url ) ) {
        exit;
      }
      echo 'unable to redirect, maybe the post wasn't published';;
    }
    

    Thank you, I’ve had to do a workaround for this, redirecting to the last post created, haha 🙂

    Thanks again.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    cool! Happy coding!

    Do leave a review when you a moment to spare!

    @aurovrata in your code

    
    //from FAQ #1...
    if(isset($_GET['cf72post'])){
      $post_id = get_transient($_GET['cf72post']);
      //get the link to the new post,
      $url = get_permalink($post_id);
      if ( wp_redirect( $url ) ) {
        exit;
      }
      echo 'unable to redirect, maybe the post wasn\'t published';
    }
    

    You mistakenly added the column twice and I added the missing \t. But how do I reset prefilled data for the user?
    I tried your approach and it worked like a breeze. Thank you!

    Plugin Author Aurovrata Venet

    (@aurovrata)

    @pensebien

    You mistakenly added the column twice and I added the missing \t.

    thanks for pointing this out.

    But how do I reset prefilled data for the user?

    that’s a different question to this thread. Please start your own thread, thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.