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); }
/** * 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'])); }
/** * This function will create new registration forms for students and parents. * * This function is responsible for creating new registration forms for both * students and parents. This function will only create new registration forms * for students and parents if it is used ONLY in conjunction with the form * used to create new music competitions. * * @param Entry Object $entry The entry that was just submitted * @param Form Object $form The form used to submit entries * * @since 1.0.0 * @author KREW */ public static function aria_create_teacher_and_student_forms($confirmation, $form, $entry, $ajax) { // make sure the create competition form is calling this function $competition_creation_form_id = ARIA_API::aria_get_create_competition_form_id(); if ($form['id'] === $competition_creation_form_id) { /* Calls wp_die and returns a value of 86? self::aria_update_page_ids(); */ $field_mapping = self::aria_get_competition_entry_meta(); $competition_name = $entry[$field_mapping['Name of Competition']]; // create the student and teacher forms $student_form_id = self::aria_create_student_form($entry); $teacher_form_id = self::aria_create_teacher_form($entry, unserialize($entry[(string) $field_mapping['Volunteer Times']])); $student_form_url = self::aria_publish_form("{$competition_name} Student Registration", $student_form_id); $teacher_form_url = self::aria_publish_form("{$competition_name} Teacher Registration", $teacher_form_id); // create the sutdent and teacher (master) forms $student_master_form_id = ARIA_Create_Master_Forms::aria_create_student_master_form($competition_name); $teacher_master_form_id = ARIA_Create_Master_Forms::aria_create_teacher_master_form($competition_name); $related_forms = array('student_public_form_id' => $student_form_id, 'teacher_public_form_id' => $teacher_form_id, 'student_master_form_id' => $student_master_form_id, 'teacher_master_form_id' => $teacher_master_form_id, 'student_public_form_url' => $student_form_url, 'teacher_public_form_url' => $teacher_form_url); $student_public_form = GFAPI::get_form($student_form_id); $teacher_public_form = GFAPI::get_form($teacher_form_id); $student_master_form = GFAPI::get_form($student_master_form_id); $teacher_master_form = GFAPI::get_form($teacher_master_form_id); $student_public_form['aria_relations'] = $related_forms; $teacher_public_form['aria_relations'] = $related_forms; $student_master_form['aria_relations'] = $related_forms; $teacher_master_form['aria_relations'] = $related_forms; GFAPI::update_form($student_public_form); GFAPI::update_form($teacher_public_form); GFAPI::update_form($student_master_form); GFAPI::update_form($teacher_master_form); $teacher_public_form = GFAPI::get_form($teacher_form_id); $confirmation = 'Congratulations! A new music competition has been '; $confirmation .= 'created. The following forms are now available for '; $confirmation .= ' students and teachers to use for registration: </br>'; $confirmation .= "<a href={$student_form_url}>{$competition_name} Student Registration</a>"; $confirmation .= " was published. </br>"; $confirmation .= "<a href={$teacher_form_url}> {$competition_name} Teacher Registration </a>"; $confirmation .= " was published."; return $confirmation; } else { wp_die("ERROR: No form currently exists that allows the festival chairman\n to create a new music competition \n FormID: {$form[id]} \n func_call {$competition_creation_form_id}"); } }