Is it possible to assign a custom post title name to the post ID upon submitting an ACF form? I'm trying to do this because I don't use the custom post title, instead I just want it to be the post ID. I'm using the "twentythirteen" template.
Here's what I have to assign the post title from ACF fields in the functions.php:
function auto_title_insert( $value ) {
if ( !$value ) :
$value = $_POST['fields']['field_538626f57e84c'].' '.$_POST['fields']['field_538627ffeccb0'].' '.$_POST['fields']['field_53863a5c7502b'].' '.$_POST['fields']['fields[field_53a9bb09f82ba]'];
return $value;
endif;
return $value;
}
add_filter( 'title_save_pre', 'auto_title_insert' );
The problem is, the title doesn't change when the custom post type is updated
Here's what I have for when the post is updated:
function my_acf_update_value( $value, $post_id, $field ) {
global $_POST;
// vars
$new_title = get_field('make', $post_id) . ' ' . $value;
$new_slug = sanitize_title( $new_title );
// update post
// http://codex.wordpress.org/Function_Reference/wp_update_post
$my_post = array(
'ID' => $post_id,
'post_title' => $new_title,
'post_name' => $new_slug
);
// Update the post into the database
wp_update_post( $my_post );
}
add_filter('acf/update_value/make=make', 'my_acf_update_value', 10, 3);
The problem is I can only get it to work for one custom field instead of updating multiple fields
Here's what I have to make the title name the time stamp:
function auto_title_insert( $value ) {
if ( !$value ) :
$value = '['.get_the_date('d/m/Y @ H:i:s').']';
endif;
return $value;
}
add_filter( 'title_save_pre', 'auto_title_insert' );
That's ok, but I really want the post ID for organization