Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@iamgabrielma
Created August 21, 2018 11:24
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 iamgabrielma/6029642abb31fcbb52c45224ffb0f780 to your computer and use it in GitHub Desktop.
Save iamgabrielma/6029642abb31fcbb52c45224ffb0f780 to your computer and use it in GitHub Desktop.
Stop Jetpack Publicize from sharing new WP Job Manager job listings submitted via the front-end
/**
* Stop Jetpack Publicize sharing posts from the frontend job submit form entries
*
* @param $new_status
* @param $old_status
* @param $post
*/
function prefix_flag_post_for_publicize( $new_status, $old_status, $post ) {
// Make sure the job_manager_form is set, it is the job_listing post type and the post status is publish
if ( ! isset( $_POST['job_manager_form'] ) || $post->post_type != 'job_listing' || $new_status != 'publish' ) {
return;
}
// If it is the submit-job form on the frontend, set the jetpack filter to return false
if ( $_POST['job_manager_form'] == 'submit-job' ) {
add_filter( 'publicize_should_publicize_published_post', '__return_false' );
}
}
// Set the priority to 9 so it runs before the Jetpack version
add_action( 'transition_post_status', 'prefix_flag_post_for_publicize' , 9, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment