I found that if I’m logged in doubles, if the page loads without being logged in it works perfectly. I found this information on this link https://stackoverflow.com/questions/18397400/wp-insert-post-creates-two-pages?rq=1 , the curious thing is to know why it happens.
As you said yourself, for security purposes, this page should only be performed by the site administrator after login.
it ‘ s my code:
function add_post($conteudo){
$my_post = array(
'post_title' => $conteudo['titulo'] ,
'post_status' => 'draft',
'post_autor' => 1,
'post_type' => 'corrida',
'post_content' => '',
);
$post_id = wp_insert_post( $my_post);
update_field( 'data', $conteudo['data'], $post_id );
update_field( 'site', $conteudo['link'], $post_id );
return $post_id;
}