Skip to content

Instantly share code, notes, and snippets.

@bryceadams
Created February 11, 2015 16:54
Show Gist options
  • Save bryceadams/ccabbc3d5f73f16bad33 to your computer and use it in GitHub Desktop.
Save bryceadams/ccabbc3d5f73f16bad33 to your computer and use it in GitHub Desktop.
<?php
// Add a new field
add_filter( 'job_application_form_fields', 'custom_job_application_form_fields' );
function custom_job_application_form_fields( $fields ) {
$fields[ 'your_field' ] = array(
'label' => 'Label for field',
'type' => 'text',
'required' => true,
'placeholder' => 'Placeholder text',
'priority' => 6
);
$fields[ 'second_field' ] = array(
'label' => 'Second for field',
'type' => 'text',
'required' => true,
'placeholder' => 'Placeholder text',
'priority' => 6
);
return $fields;
}
// Add new field data to meta array so its saved and stored
add_filter( 'job_application_form_posted_meta', 'custom_job_application_form_posted_meta' );
function custom_job_application_form_posted_meta( $meta ) {
$meta['your_field'] = sanitize_text_field( $_POST['your_field'] );
$meta['second_field'] = sanitize_text_field( $_POST['second_field'] );
return $meta;
}
// Add a line to the notifcation email with custom field
add_filter( 'create_job_application_notification_message', 'custom_create_job_application_notification_message', 10, 2 );
function custom_create_job_application_notification_message( $message, $application_id ) {
$message[] = "\n" . "Your field was set as: " . get_post_meta( $application_id, 'your_field', true );
$message[] = "\n" . "Your second field was set as: " . get_post_meta( $application_id, 'second_field', true );
return $message;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment