Hi all,
I have an ACF frontend form which creates a new post
acf_form( array(
'id' => 'edit-survey',
'field_groups' => array( 53 ),
'post_id' => absint( $_GET['survey'] ),
'return' => add_query_arg( 'survey', '%post_id%', get_the_permalink() ),
'submit_value' => 'Save Survey',
)
);
I am then trying to filter the POST OBJECT field within the field_group 53. But when I try to use $post_id I am only getting ‘new_post’ returned and not the actual $post_id.
The code I am using:
add_filter( 'acf/fields/post_object/query/name=survey_id', function( $args, $field, $post_id ) {
$args['meta_query'] = array(
array(
'key' => 'user_id',
'value' => get_current_user_id(),
'compare' => '=',
),
array(
'key' => '_parent_survey',
'value' => $post_id, // << RETURNING 'new_post'
'compare' => '=',
),
);
return $args;
}, 10, 3 );
Any suggestions? 🙂
Many thanks
EDIT: Code formatting didnt work when posting so I removed tabs.