我们可以为“简历管理器”设置不同类型的字段(&;保存它。我们可以通过过滤器实现这一点,如下所示,
//code to add custom field for Resume Manager on front end
add_filter( \'submit_resume_form_fields\', \'wdm_customize_resume_fields\' );
function wdm_customize_resume_fields($fields)
{
$fields[\'resume_fields\'][\'candidate_address\'] = array(
\'label\' => __( \'Your Address\', \'wp-job-manager-resumes\' ),
\'type\' => \'text\',
\'required\' => false,
\'description\' => __(\'Add your address here\',\'wp-job-manager-resumes\'),
\'priority\' => 2
);
return $fields;
}
在这里,您可以指定新字段、添加其标签、为其键入以及使用“优先级”指定其位置。
现在我们需要保存字段,我们可以使用以下代码,
add_action( \'resume_manager_update_resume_data\', \'wdm_save_resume_custom_field\', 10, 2 );
function wdm_save_resume_custom_field( $resume_id, $values ) {
if(!empty($resume_id) && !empty($values)) {
if(isset($values[\'resume_fields\'][\'candidate_address\']) {
update_post_meta( $resume_id, \'_candidate_address\', $values[\'resume_fields\'][\'candidate_address\'] );
}
}
}
如果已设置,这将更新“\\u Candidate\\u address”元密钥中的候选地址。
此保存的字段也需要显示在仪表板中。我们可以通过以下方式实现这一目标:,
add_filter( \'resume_manager_resume_fields\', \'wdm_resume_fields_dashboard\' );
function wdm_resume_fields_dashboard($fields){
$fields[\'_candidate_address\'] = array(
\'label\' => __( \'Your Address\', \'wp-job-manager-resumes\' ),
\'placeholder\' => __( \'Add your address here\', \'wp-job-manager-resumes\' ),
\'type\' => \'text\'
);
return $fields;
}