Ok, I am following your advice. Can you point me in the right direction on how to pass the proposal id in the post object filter code? I am trying to figure out where to look..
Thank a lot!
function assign_proposal_to_review( $args, $field, $post_id ) {
// only show children of the current post being edited
$args['page_id'] = '???';
// return
return $args;
}
add_filter('acf/fields/post_object/query/name=proposal_reviewed', 'assign_proposal_to_review', 10, 3);
Thank you very much for your reply James. Just a question: using the update field is not the right method, isn’t it?
I was able to pass post ID in the new_review.php:
<?php $id_contributo = $_POST['id_contributo']; ?>
//get proposal idfrom previous page
<h3>Proposal reviewed: <?php echo $id_contributo; ?></h3>//display original proposal title
<?php update_field('proposal_reviewed', $id_contributo);?> //update post object field content
<?php echo get_field('id_contributo');?> //echo the value
//form used to create the new review
<?php acf_form(array(
'post_id' => 'new_review',
'submit_value' => 'Create',
));?>
and in function.php:
function my_pre_save_review( $post_id ) {
// bail early if not a new review
if( $post_id != 'new_review' ) {
return $post_id;
}
// Create a new post
$review = array(
'post_status' => 'publish',
'post_type' => 'reviews',
);
$post_id = wp_insert_post( $review );
// return the new ID
return $post_id;
}
add_filter('acf/pre_save_post' , 'my_pre_save_review' );
Echoing the value in the front-end works, but if I open the review from admin panel the object field is not updated.