Home › Forums › Front-end Issues › Using acf_form for multiple post_type › Reply To: Using acf_form for multiple post_type
Hi @enricospada
Thanks for the clarification. For your filter to know which form posted the data, you will need to use the ‘post_id’ parameter.
If you look at the tutorial here:
http://www.advancedcustomfields.com/resources/tutorials/using-acf_form-to-create-a-new-post/
You will see that the filter function contains a check on the $post_id parameter:
// check if this is to be a new post
if( $post_id != 'new' )
{
return $post_id;
}
This ‘new’ comes from the acf_form $options array and you can customize it!
Therefore, on form 1, you could set this as ‘new_1’, and on form 2 ‘new_2’, etc.
Then you can set up 2 functions hooked into the pre_save_post filter and use the validation like so:
// check if this is to be a new post
if( $post_id != 'new_1' )
{
return $post_id;
}
Hope that helps.
Thanks
E
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.