Tutorial: Stop Jetpack Publicize from sharing new job listings

Note: All code examples on this site are provided for developer reference/guidance only and we cannot guarantee that they will always work as expected. Our support policy does not include assistance with modifying or debugging code from any code examples, and they may be changed or removed if we find they no longer work due to changes in our plugins.

If you’re using Jetpack Publicize to share your blog posts on social media, you’ll notice that new job listings submitted via the front-end use publicize by default and these will also be shared automatically.

This happens because a job listing is a special custom post type, and while you can opt-out from this via wp-admin as an administrator of the site, front-end submissions won’t be able to opt-out this behavior.

If you’d like to avoid this, simply add the following code to your functions.php file or via a plugin like Code Snippets:

/**
* 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 );