Home › Forums › ACF PRO › Custom Post Title with Front End Form ? › Reply To: Custom Post Title with Front End Form ?
I’v tried adding this to the head of my template file (and also in functions.php) but still no title is created?
function my_pre_save_post( $post_id ) {
/*var_dump( $post_id ); // OUTPUT: NULL
var_dump( $_POST['post_id'] ); // OUTPUT: string(3) "new"
die();*/
if ( $post_id != 'new_post' ) {
return $post_id;
}
$post = array(
'post_title' => 'A custom title',
);
$post_id = wp_insert_post( $post );
return $post_id;
}
add_filter( 'acf/pre_save_post', 'my_pre_save_post', 10, 1 );
Any other ideas?
Thanks for the help.
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.