/** * Submit Step */ public static function submit() { global $job_manager, $post; self::init_fields(); // Load data if neccessary if (!empty($_POST['edit_job']) && self::$job_id) { $job = get_post(self::$job_id); foreach (self::$fields as $group_key => $fields) { foreach ($fields as $key => $field) { switch ($key) { case 'job_title': self::$fields[$group_key][$key]['value'] = $job->post_title; break; case 'job_description': self::$fields[$group_key][$key]['value'] = $job->post_content; break; case 'job_type': self::$fields[$group_key][$key]['value'] = current(wp_get_object_terms($job->ID, 'job_listing_type', array('fields' => 'slugs'))); break; case 'job_category': self::$fields[$group_key][$key]['value'] = current(wp_get_object_terms($job->ID, 'job_listing_category', array('fields' => 'slugs'))); break; default: self::$fields[$group_key][$key]['value'] = get_post_meta($job->ID, '_' . $key, true); break; } } } self::$fields = apply_filters('submit_job_form_fields_get_job_data', self::$fields, $job); // Get user meta } elseif (is_user_logged_in() && empty($_POST)) { if (!empty(self::$fields['company'])) { foreach (self::$fields['company'] as $key => $field) { self::$fields['company'][$key]['value'] = get_user_meta(get_current_user_id(), '_' . $key, true); } } if (!empty(self::$fields['job']['application'])) { $allowed_application_method = get_option('job_manager_allowed_application_method', ''); if ($allowed_application_method !== 'url') { $current_user = wp_get_current_user(); self::$fields['job']['application']['value'] = $current_user->user_email; } } self::$fields = apply_filters('submit_job_form_fields_get_user_data', self::$fields, get_current_user_id()); } wp_enqueue_script('wp-job-manager-job-submission'); get_job_manager_template('job-submit.php', array('form' => self::$form_name, 'job_id' => self::get_job_id(), 'action' => self::get_action(), 'job_fields' => self::get_fields('job'), 'company_fields' => self::get_fields('company'), 'submit_button_text' => __('Preview job listing →', 'wp-job-manager'))); }