ACF with custom Post Type Query
-
Hello,
I’m trying to catch an acf form and update a repeater row in difrent post type.
this is what I do:
add_action('acf/save_post', 'Add_Flight_acf_save_post'); function Add_Flight_acf_save_post( $post_id ) { // Get newly saved values. $values = get_fields( $post_id ); // Check the new value of a specific field. $flight_departure_date = $values['flight_departure_date']; if( $flight_departure_date ) { $UserId = get_field('user_id', $post_id); $row = array( 'posts_id' => $post_id, 'posts_name' => 'flight', ); $meta_query_args = array( array( 'key' => 'user_id', 'value' => $user_id, ), array( 'key' => 'date_of_day', 'compare' => '=', 'value' => $flight_departure_date, ) ); $args = [ 'posts_per_page' => -1, 'post_type' => 'day', 'meta_query' => $meta_query_args ]; $AddSchedules = get_posts( $args ); foreach( $AddSchedules as $Schedule ){ add_row('post_list', $row, $Schedule->ID); } } }basically what i’m trying to do is: get values from add flight form in acf_form(), take the id of the new post and the user id and put them in every post type “day” where the user id and the date is the same as the values and put in the post type “day” the repeated row $row
if I use only the date as value of search without the user id it works perfectly. but I must check the user id also.
I dont want the flight to enter in all users that fly in this day
The topic ‘ACF with custom Post Type Query’ is closed to new replies.