roles; if ( in_array( 'administrator', $roles, true ) ) { return $conditions; } if ( in_array( 'booktics_team_member', $roles, true ) ) { $order_ids = $this->get_order_ids(); $conditions['id'] = [ 'in', $order_ids ]; } return $conditions; } /** * Get order ids for a date range * * @param array $dates * * @return array */ private function get_order_ids() { $order_ids = ['null']; $args = []; $args = apply_filters( 'booktics_appointment_args', $args ); $appointments = ( new Appointment_Model() )->all( $args ); foreach ( $appointments as $appointment ) { $order_ids[] = $appointment->order_id; } return $order_ids; } }