When I save the post It create one post with correct value and an other with no title and no value!
add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post' );
function tsm_do_pre_save_post( $post_id ) {
// Create a new post
$post = array(
'post_type' => 'itemfounds', // Your post type ( post, page, custom post type )
'post_status' => 'draft', // (publish, draft, private, etc.)
'post_title' => 'ÎÏÏεά Ïε ÎµÎ¯Î´Î¿Ï Î³Î¹Î± Ïο "'.get_the_title(wp_strip_all_tags( $_POST['acf']['field_5696694332974'] )).'"' , // Post Title ACF field key
);
// insert the post
$post_id = wp_insert_post( $post );
session_start();
$_SESSION['item_pid'] = $post_id;
// Save the fields to the post
// do_action( 'acf/save_post' , $post_id );
return $post_id;
}
You can use acf by this way:-
$post_id
(array) the ID of the post being savedBEFORE
AFTER
Hope this will help you 🙂