Hi Christian, I hope you're well. Thank you as always for your excellent help. Unfortunately I think that I haven't explained my issue quite correctly, so my apologies for that.
Although your answer helps me understand the function that I needed to create (for after the initial User Form is submitted - using the 'cred_save_data' action), I'm not getting the desired outcome:
I need to be able to dynamically load up the details of the Client 'Post' (that gets auto-generated after I submit the User Form), into the Post Form on my redirection page (so the Post Form is a form to update 'existing' posts, not add new posts). I think the code you have given me would allow me to pre-populate the fields for a 'new' post. However, in this case, the post is already setup, so I need the details for that post to load into the Post Form on my redirection page (that Post Form is to edit existing posts, not to create new ones).
I realise that I might not be explaining myself very well - so I have drawn a flow diagram, which hopefully makes it easier to understand - please see my attached image which explains things better (I hope!) Basically my question is shown twice, once in red and once in blue, but they are the same question (I have just tried to explain it in 2 different ways to try and explain better!).
Just to confirm, step 1, 2 and 3 in the diagram are all working fine, it is just Step 4 which I am trying to solve in this thread.
So I just need to be able to get the Post ID of the automatically generated Client Post (the post in the orange box), and then to be able to add that to the URL of the redirection (but again if you see my flow diagram I think this will explain it better). After looking around the forum I have stumbled on some code which I have tried to adapt (and I also found the 'wpv-search-term param' shortcode bit in some other threads), and I added this code to my functions.php - please see my code below:
add_filter('cred_success_redirect', 'after_client_setup_redirect',10,3);
function after_client_setup_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==146) {
$redirect = $url . "?client_post_id" . $post_id;
return $redirect;
}
return $url;
}
But unfortunately this code does not work, it is pasting an incorrect post ID into the URL (it was a stab in the dark from me haha).
Please let me know if you need any more information from me.
And once again, thank you SO MUCH for your excellent support 🙂
Keith