/** * Function to get pre-populate values based on student-master. */ public static function aria_get_student_pre_populate($prepended_title, $student_hash) { $all_forms = self::aria_find_related_forms_ids($prepended_title); $hash_field_id = ARIA_Create_Master_Forms::aria_master_student_field_id_array()['hash']; $search_criteria = array('field_filters' => array('mode' => 'any', array('key' => (string) $hash_field_id, 'value' => $student_hash))); $entries = GFAPI::get_entries($all_forms[self::STUDENT_MASTER], $search_criteria); if (is_wp_error($entries)) { wp_die($entries->get_error_message()); } $field_ids = ARIA_Create_Master_Forms::aria_master_student_field_id_array(); return array('parent_name' => rgar($entries[0], (string) $field_ids['parent_name']), 'parent_email' => rgar($entries[0], (string) $field_ids['parent_email']), 'student_name' => rgar($entries[0], (string) $field_ids['student_name']), 'student_birthday' => rgar($entries[0], (string) $field_ids['student_birthday']), 'teacher_name' => rgar($entries[0], (string) $field_ids['teacher_name']), 'not_listed_teacher_name' => rgar($entries[0], (string) $field_ids['not_listed_teacher_name']), 'available_festival_days' => rgar($entries[0], (string) $field_ids['available_festival_days']), 'preferred_command_performance' => rgar($entries[0], (string) $field_ids['preferred_command_performance']), 'song_1_period' => rgar($entries[0], (string) $field_ids['song_1_period']), 'song_1_composer' => rgar($entries[0], (string) $field_ids['song_1_composer']), 'song_1_selection' => rgar($entries[0], (string) $field_ids['song_1_selection']), 'song_2_period' => rgar($entries[0], (string) $field_ids['song_2_period']), 'song_2_composer' => rgar($entries[0], (string) $field_ids['song_2_composer']), 'song_2_selection' => rgar($entries[0], (string) $field_ids['song_2_selection']), 'theory_score' => rgar($entries[0], (string) $field_ids['theory_score']), 'alternate_theory' => rgar($entries[0], (string) $field_ids['alternate_theory']), 'competition_format' => rgar($entries[0], (string) $field_ids['competition_format']), 'timing_of_pieces' => rgar($entries[0], (string) $field_ids['timing_of_pieces']), 'hash' => rgar($entries[0], (string) $field_ids['hash'])); }
public static function aria_after_teacher_submission($form, $entry) { // Get the query variables from the link $student_hash = get_query_var("student_hash", false); $teacher_hash = get_query_var("teacher_hash", false); // Get field id arrays $student_master_field_ids = ARIA_Create_Master_Forms::aria_master_student_field_id_array(); $teacher_master_field_ids = ARIA_Create_Master_Forms::aria_master_teacher_field_id_array(); $teacher_public_field_ids = ARIA_Create_Competition::aria_master_teacher_field_id_array(); // Update the teacher entry in the teacher master. $teacher_master_entry = ARIA_Registration_Handler::aria_find_teacher_entry($form["title"], $teacher_hash); if (!teacher_entry) { wp_die("Error"); } $teacher_master_entry[(string) $teacher_master_field_ids['name']] = $entry[(string) $teacher_public_field_ids['name']]; $teacher_master_entry[(string) $teacher_master_field_ids['email']] = $entry[(string) $teacher_public_field_ids['email']]; $teacher_master_entry[(string) $teacher_master_field_ids['phone']] = $entry[(string) $teacher_public_field_ids['phone']]; $teacher_master_entry[(string) $teacher_master_field_ids['volunteer_preference']] = $entry[(string) $teacher_public_field_ids['volunteer_preference']]; $teacher_master_entry[(string) $teacher_master_field_ids['volunteer_time']] = $entry[(string) $teacher_public_field_ids['volunteer_time']]; $teacher_master_entry[(string) $teacher_master_field_ids['is_judging']] = $entry[(string) $teacher_public_field_ids['is_judging']]; // Update the student entry in the student master. $student_master_entry = ARIA_Registration_Handler::aria_find_student_entry($form["title"], $student_hash); if (!student_entry) { wp_die("Error"); } $student_master_entry[(string) $student_master_field_ids['student_name']] = $entry[(string) $teacher_public_field_ids['student_name']]; $student_master_entry[(string) $student_master_field_ids['song_1_period']] = $entry[(string) $teacher_public_field_ids['song_1_period']]; $student_master_entry[(string) $student_master_field_ids['song_1_composer']] = $entry[(string) $teacher_public_field_ids['song_1_composer']]; $student_master_entry[(string) $student_master_field_ids['song_1_selection']] = $entry[(string) $teacher_public_field_ids['song_1_selection']]; $student_master_entry[(string) $student_master_field_ids['song_2_period']] = $entry[(string) $teacher_public_field_ids['song_2_period']]; $student_master_entry[(string) $student_master_field_ids['song_2_composer']] = $entry[(string) $teacher_public_field_ids['song_2_composer']]; $student_master_entry[(string) $student_master_field_ids['song_2_selection']] = $entry[(string) $teacher_public_field_ids['song_2_selection']]; $student_master_entry[(string) $student_master_field_ids['theory_score']] = $entry[(string) $teacher_public_field_ids['theory_score']]; $student_master_entry[(string) $student_master_field_ids['alternate_theory']] = $entry[(string) $teacher_public_field_ids['alternate_theory']]; $student_master_entry[(string) $student_master_field_ids['competition_format']] = $entry[(string) $teacher_public_field_ids['competition_format']]; $student_master_entry[(string) $student_master_field_ids['timing_of_pieces']] = $entry[(string) $teacher_public_field_ids['timing_of_pieces']]; $teacher_result = GFAPI::update_entry($teacher_master_entry); $student_result = GFAPI::update_entry($student_master_entry); }