I have managed it to work i was trying not to work on with hooks like the plugin developers suggest, but the solution was with hook.
Here is the documentation example of the plugin
But i need to edit the content of the post too so i make a loop to find the post you can create a query to get it too it will be ok too. So i get the content like this:
<?php
$current_post = isset($_GET['post'])?intval($_GET['post']):'new';
acf_form_head();
?>
<?php get_header(); ?>
<?php
if($current_post!='new')
{
?>
<?php
$query = new WP_Query( array( 'post_type' => 'post', 'posts_per_page' => '-1', 'page_id'=>$current_post,'author'=>$current_user->ID ) ); ?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<?php
$title = get_the_title();
$content = get_the_content();
$post_categories = wp_get_post_categories( get_the_ID() );
$cats = array();
foreach($post_categories as $c){
$cat = get_category( $c );
$cats[] = $cat->cat_ID;
}
?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
<?php }
else
{
$title="";
$content="";
}
?>
And then in the function.php i have a filter which get the information when the form is submitted like this:
function my_pre_save_post( $post_id )
{
$current_post = isset($_GET['post'])?intval($_GET['post']):'';
if($_POST['cat'])
{
$cats = $_POST['cat'];
foreach($cats as $catp)
{
$catobject = get_category($catp,false); // Get the Category object by the id of current category
if($catobject->category_parent); // the id of the parent category
{
array_push($_POST['cat'],$catobject->category_parent);
}
}
$_POST['cat']=array_unique($_POST['cat']);
}
// Create a new post
$post_information = array(
'post_title' => wp_strip_all_tags( $_POST['postTitle'] ),
'post_content' => $_POST['postContent'],
'post_type' => 'post',
'post_status' => 'pending',
'post_category'=>$_POST['cat']
);
if($current_post)
{
$post_information['ID'] = $current_post;
}
// insert the post
$post_id = wp_insert_post( $post_information );
$_POST['return'] = add_query_arg( array('post' => $post_id), $_POST['return'] );
// return the new ID
return $post_id;
}
Also i clear some options in the options table with fields starting with “new_” and add this code to separate the new post from the old when call the advanced custom fields visualization.
<?php $args = array(
'post_id' => $current_post ,
'field_groups' => array( 19 )
);
acf_form( $args ); ?>
This things resolve my problem so i wanted to share with someone which experience the same problems.