Home › Forums › Front-end Issues › Set title on acf_form › Reply To: Set title on acf_form
As an example, this will set the post title on save or update from input fields.
<?php // SET TITLE ON SAVE & UPDATE
function my_post_title_updater($post_id) {
if ( get_post_type( $post_id ) == 'account' ) {
$my_post = array(
'ID' => $post_id,
'post_title' => get_field( 'last_name', $post_id ) . ', ' . get_field( 'first_name', $post_id ),
);
wp_update_post( $my_post );
}
}
add_action('acf/save_post', 'my_post_title_updater', 20); // run after ACF saves the $_POST['fields'] data
?>
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.