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?
This is currently working on a custom post type for me.
/**
* Front end creation of new download
* @author Mike Hemberger
* @link http://thestizmedia.com
* @uses Advanced Custom Fields Pro
*/
add_filter('acf/pre_save_post' , 'jivedig_newdownload_pre_save_post' );
function jivedig_newdownload_pre_save_post( $post_id ) {
// check if this is to be a new post
if( $post_id != 'new' ) {
return $post_id;
}
// Create a new post
$post = array(
'post_status' => 'publish',
'post_title' => $_POST['acf']['field_5483b32a04842'], // beat_title
'post_type' => 'download',
);
// 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;
}
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.