Home › Forums › Front-end Issues › Using acf_form for multiple post_type › Reply To: Using acf_form for multiple post_type
Thanks, Daniel. That’s really useful info which I’m sure I’ll use in the future.
However, right now I’m trying to do this through separate forms. That is, I have multiple forms on my site but they each update a different post-type.
This is in my functions.php:
// ACF SAVE NEW POST
function my_pre_save_post( $post_id )
{
// Create a new post
$post = array(
'post_status' => 'publish' ,
'post_title' => $_POST['fields']['field_52d978ea24ac7'],
'post_type' => 'location' ,
);
// insert the post
$post_id = wp_insert_post( $post );
// update $_POST['return']
$_POST['return'] = add_query_arg( array('post_id' => $post_id), $_POST['return'] );
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_post' );
This makes sense and works perfectly for one form — but if I add a second form to update a second post type, it doesn’t work. What do I need to modify so that I can have more than one form?
Cheers,
Enrico
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.