Home Forums Front-end Issues Set post object field using php Reply To: Set post object field using php

  • 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.