public function form_render($form) { foreach ($form['fields'] as $i => &$field) { if ($field->id == 1) { $field->choices = array_map(function ($event) { return array('value' => $event->ID, 'text' => $event->post_title); }, get_user_attended_events_without_feedback()); } } return $form; }
public function populate_user_events_field($form) { foreach ($form['fields'] as &$field) { if ($field['label'] == 'Event') { $field['choices'] = array_map(function ($post) { return array('text' => $post->post_title, 'value' => $post->ID); }, get_user_attended_events_without_feedback()); } } return $form; }