
Hi SaskiaB! I solved it by adding a hidden input field to the form.
So in my page:
$bio_args = array(
'post_id' => 'new_artist',
'field_groups' => array( 55 ),
'submit_value' => 'Submit my Bio',
// 'return' =>
'html_after_fields' => '<input type="hidden" name="post_type" value="frp_artist">'
);
?>
<?php acf_form( $bio_args ); ?>
Then in my functions:
function wnc_bio_frontend( $post_id )
{
// check if this is to be a new post
if( $post_id != 'new_artist' )
{ return $post_id; }
// Create a new post
$tax_actors = array(
$_POST['fields']['field_5439adfebbbcb'],
);
$post = array(
'post_status' => 'pending',
'post_title' => $_POST['fields']['field_5439aa052a606'],
'post_type' => $_POST['post_type'],
'tax_input' => $tax_actors,
);
// 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' , 'wnc_bio_frontend' );
Notice the “post type” hidden field. I hope that helps!
Hi! Do you mind explaining how you solved the prefilled form issue? Were you able to use ‘autocomplete=”false”? If so, where did you put that?
Thanks for the help.
P.S. I love this plugin! It’s amazing!
That was exactly right… knew it was something like that. 😉 Thanks for the fast reply.