Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created January 24, 2017 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/cbb04b5d45d607703a2486c7ba6c8acd to your computer and use it in GitHub Desktop.
Save tripflex/cbb04b5d45d607703a2486c7ba6c8acd to your computer and use it in GitHub Desktop.
Allow empty Resume Content (resume_content) field in WP Job Manager (to prevent white screen of death)
<?php
// This filter handles preventing fatal error from empty value in post_content
add_filter( 'submit_resume_form_save_resume_data', 'submit_listing_allow_empty_resume_content', 99999, 5 );
/**
* Allow empty Resume Content (resume_content) field in WP Job Manager
*
* If you're using the Field Editor plugin, and want to configure the Resume Content (resume_content meta key) field
* to only show for specific packages, you will need this code to prevent a white screen of death, as the core
* WP Job Manager plugin requires this value to not be NULL. This function will filter the core WP Job Manager
* resume data, and set the post_content (used for resume_content meta key) to an empty string, instead of NULL.
*
*
* @param $resume_data
* @param $post_title
* @param $post_content
* @param $status
* @param $values
*
* @return mixed
*/
function submit_listing_allow_empty_resume_content( $resume_data, $post_title, $post_content, $status, $values ){
/**
* If we disabled the resume_content meta key field, the post_content value will be NULL,
* so we set it to an empty string to prevent any fatal PHP errors (or blank screen on preview)
*/
if( $resume_data['post_content'] === NULL ) {
$resume_data['post_content'] = '';
}
return $resume_data;
}
@tripflex
Copy link
Author

You can find this same code for Job Listings here:
https://gist.github.com/tripflex/c2bfdb855f6516263a9825dbacbedea4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment