When using Advanced Forms Pro to create posts, you may need to redirect to a custom URL and pass the ID of the new post along with the redirect. You may do this by using the af/form/editing/post_created hook and overriding the redirect URL set in the form args on the submission as per the following example.
add_action( 'af/form/editing/post_created', function ( $post, $form, $args ) { // If we aren't handling the desired form, return early. if ( $form['key'] !== 'FORM_KEY_HERE' ) { return; } // Override the redirect URL for this submission using the post ID. AF()->submission['args']['redirect'] = 'https://example.com?post=' . $post->ID; }, 10, 3 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article