Hello,
How can I get the post_id created when I submit my form ? I want to redirect the user to another page. I try to use the “return” parameter for that.
Something like that :
$edit_tickets = add_query_arg('post', $post_evt_id, get_permalink(1234 + $_POST['post_id']));
// Create Form with redirection to the new post
$new_post = array(
'post_id' => 'new', // Create a new post
'field_groups' => array('group_54dfc93792c38'), // Create post field group ID(s)
'form' => true,
'return' => $edit_tickets, // Redirect to new post url
'html_before_fields' => '',
'html_after_fields' => '',
'submit_value' => 'Poster',
'updated_message' => 'Saved!'
);
acf_form($new_post);
Thanks a lot for your help,
Hi @jacquesmivi
If you want to redirect it to the newly created post, kindly use the %post_url%
tag like this:
'return' => %post_url%,
This page should give you more idea about it: https://www.advancedcustomfields.com/resources/acf_form/.
If you need to generate the link based on the newly created post ID, then I suggest you do the redirection by using the wp_redirect() function in the acf/save_post action instead.
I hope this helps 🙂
This reply has been marked as private.