Context -
I am creating a temp job post to act as a dummy while I call the real job post using generic field and make changes to it.
This happens because the temp job form has two purposes:
1) It can be used to create new job post if one does not exist, and does the rest of the processing.
2) It acts a temp job post, if the job post exists and then does the processing.
Now, all is well is option (1). But, in option (2), I am using the previous job post to do stuff and redirect the user to a custom page. However, in the end, I am left with a temp post.
Can I delete this temp post with a hook (may be the redirect hook as it is the last one in use with a later priority number)? This way all the work I need to do will be done and in the very end the temp post will be deleted.
Can that work or are there limitations on deleting a post that calls the action?
Hello,
Is there any relationship between the temp job post and real job post?
How do you redirect user to the "custom page"?
If you redirect user after submit a Toolset post form, you can try the action hook "cred_success_redirect":
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
use it to trigger a custom PHP function, get the related "temp post", and delete it:
https://developer.wordpress.org/reference/functions/wp_delete_post/
There is no relationship between the temp job post and the real job post.
It is just used as a vessel to process for primary job. The redirect happens with cred_success_redirect.
can I use two different redirects with different priority :
priority 10 - direct to new page
priority 20 - delete the temp post.
Yes, you can use different priority parameters to trigger different custom PHP function, all those PHP function will be excuted.
My issue is resolved now. Thank you!