Home › Forums › Front-end Issues › How do you create post_title from another field(s) in ACF Pro? › Reply To: How do you create post_title from another field(s) in ACF Pro?
@rockeypjb and @robnero
That’s not working with PRO. I set up the front end form like this:
acf_form( array('post_id' => 'new_post',
'new_post' => array(
'post_title' => 'Temp Title',
'post_content' => 'Temp Contents',
'post_type' => 'members',
'post_status' => 'publish' ),
'submit_value' => 'Submit',
'field_groups' => array( 17 ),
'return' => get_the_permalink() ) );
I tried it without the ‘new_post’ array, knowing that’d I’d be changing the values in a pre_save_post filter, but the post wouldn’t save without it.
Then the pre_save_post function is:
if( $post_id == 'new_post' )
{
$post = array( 'post_title' => $_POST['acf']['field_2'],
'post_content' => $_POST['acf']['field_2'],
'post_type' => 'members',
'post_status' => 'publish' );
$post_id = wp_insert_post( $post );
}
return $post_id;
None of the changes made via the pre_save_post function had any effect on the post that was saved to WP.
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.