Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WP Job Manager - Remove "preview" step
<?php
/**
* Remove the preview step. Code goes in theme functions.php or custom plugin.
* @param array $steps
* @return array
*/
function custom_submit_job_steps( $steps ) {
unset( $steps['preview'] );
return $steps;
}
add_filter( 'submit_job_steps', 'custom_submit_job_steps' );
/**
* Change button text (won't work until v1.16.2)
*/
function change_preview_text() {
return __( 'Submit Job' );
}
add_filter( 'submit_job_form_submit_button_text', 'change_preview_text' );
/**
* Since we removed the preview step and it's handler, we need to manually publish jobs
* @param int $job_id
*/
function done_publish_job( $job_id ) {
$job = get_post( $job_id );
if ( in_array( $job->post_status, array( 'preview', 'expired' ) ) ) {
// Reset expirey
delete_post_meta( $job->ID, '_job_expires' );
// Update job listing
$update_job = array();
$update_job['ID'] = $job->ID;
$update_job['post_status'] = get_option( 'job_manager_submission_requires_approval' ) ? 'pending' : 'publish';
$update_job['post_date'] = current_time( 'mysql' );
$update_job['post_date_gmt'] = current_time( 'mysql', 1 );
wp_update_post( $update_job );
}
}
add_action( 'job_manager_job_submitted', 'done_publish_job' );
@jschav88

This comment has been minimized.

Copy link

@jschav88 jschav88 commented Dec 8, 2015

Thank you for this snippet, but it doesn't work anymore with the new version of WPJM. Is there a new version available ? Thank you.

@mrsminkie

This comment has been minimized.

Copy link

@mrsminkie mrsminkie commented Dec 14, 2015

Hi Mike - thank you for this. I am using WC Paid Listings and this code removed the preview as intended, but also completely bypassed the purchasing stage. Are you able to update to accommodate? Many thanks.

@aheckler

This comment has been minimized.

Copy link

@aheckler aheckler commented Jan 12, 2016

@jschav88 and @mrsminkie — Can you file support requests on our site here? https://wpjobmanager.com/support/ Thanks! 😄

@bikedorkjon

This comment has been minimized.

Copy link

@bikedorkjon bikedorkjon commented Jun 6, 2017

I just tested this code and it appears to still work.

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jul 25, 2017

I'ts still working with the last version of wp job manager, thanks!

@rafieshaki

This comment has been minimized.

Copy link

@rafieshaki rafieshaki commented Nov 30, 2017

Hi, it is possible to remove preview step to a Resume submission with same snipet?
Thanks

@Joe-Bloggs

This comment has been minimized.

Copy link

@Joe-Bloggs Joe-Bloggs commented Dec 2, 2018

Hey there, the code possibly works on its own, but definitely doesn't work with the WC Paid Listings extension.

Just like @mrsminkie mentioned above, it removes the entire package selection step.

Is there anyway this could be fixed to make it compatible?

Thanks

@baccadiginepro

This comment has been minimized.

Copy link

@baccadiginepro baccadiginepro commented Jun 4, 2019

To make it works with WC Paid Listings extension, the first filter must be executed AFTER the same filter called by Paid Listing, having priority 20.
This can be achieved with:

add_filter( 'submit_job_steps', 'custom_submit_job_steps', 25 );

In this way the step preview is removed after the changes made by the WC Paid Listing plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.