Created
May 23, 2017 18:19
-
-
Save jom/42ebbfaabb87c17a0524a215ac77f0d3 to your computer and use it in GitHub Desktop.
Remove Preview Step for Submitting Resumes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove the preview step. Code goes in theme functions.php or custom plugin. | |
* @param array $steps | |
* @return array | |
*/ | |
function custom_submit_resume_steps( $steps ) { | |
unset( $steps['preview'] ); | |
return $steps; | |
} | |
add_filter( 'submit_resume_steps', 'custom_submit_resume_steps' ); | |
/** | |
* Change button text (won't work until v1.16.2) | |
*/ | |
function change_resume_preview_text() { | |
return __( 'Submit Resume' ); | |
} | |
add_filter( 'submit_resume_form_submit_button_text', 'change_resume_preview_text' ); | |
/** | |
* Since we removed the preview step and it's handler, we need to manually publish resumes | |
* @param int $resume_id | |
*/ | |
function done_publish_resume( $resume_id ) { | |
$resume = get_post( $resume_id ); | |
if ( in_array( $resume->post_status, array( 'preview', 'expired' ) ) ) { | |
// Reset expirey | |
delete_post_meta( $resume->ID, '_resume_expires' ); | |
// Update resume listing | |
$update_resume = array(); | |
$update_resume['ID'] = $resume->ID; | |
$update_resume['post_status'] = get_option( 'resume_manager_submission_requires_approval' ) ? 'pending' : 'publish'; | |
$update_resume['post_date'] = current_time( 'mysql' ); | |
$update_resume['post_date_gmt'] = current_time( 'mysql', 1 ); | |
wp_update_post( $update_resume ); | |
} | |
} | |
add_action( 'resume_manager_resume_submitted', 'done_publish_resume' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment