advancedforms / advanced-forms

WordPress plugin to create forms using Advanced Custom Fields
75 stars 14 forks source link

Redirect to newly created Post after Form-Submission #54

Closed MPHood closed 5 years ago

MPHood commented 5 years ago

Hey Guys! I just bought the Pro Version of your plugin today and got some questions.

First of all:

How can I redirect the User to his newly created post after submitting the Form?

I´ll open new threads for my other questions.

thanks in advance

fabianlindfors commented 5 years ago

Hi! Thank you for purchasing a license.

There is an action triggered after a post has been created called af/form/editing/post_created. Something like this should probably work:

function redirect_after_post_created( $post ) {
  wp_redirect( get_permalink( $post ) );
  exit;
}
add_action( 'af/form/editing/post_created/key=FORM_KEY', 'redirect_after_post_created' );

Let me know how it goes!

MPHood commented 5 years ago

Hey thank you for your quick answer! It helped indeed! Thank you!