Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirect to Job Dashboard after job submission
add_filter( 'submit_job_steps', 'replace_done_with_redirect' );
function replace_done_with_redirect( $steps ) {
$steps['done'] = array(
'priority' => 30,
'handler' => function() {
if ( wp_redirect( job_manager_get_permalink( 'job_dashboard' ) ) ) {
exit;
}
}
);
return $steps;
}
@joewa1980

This comment has been minimized.

Copy link

joewa1980 commented Jan 25, 2018

While it does redirect to the correct link inserted on line 7 when you submit a completed form... it submits the form to the site in a preview state rather than pending (we need it in pending for the WP Job Manager Emails plugin to hook into).

@jonasvogel

This comment has been minimized.

Copy link

jonasvogel commented Mar 27, 2018

Before redirecting, there'll be a PHP notice that this step is missing the view parameter. Also, the hook job_manager_job_submitted won't get fired, so I'd recommend to change the snippet into the following:

add_filter( 'submit_job_steps', 'replace_done_with_redirect' );

function replace_done_with_redirect( $steps ) {
    $steps['done'] = array(
        'priority' => 30,
        'handler' => function() {
            do_action( 'job_manager_job_submitted', WP_Job_Manager_Form_Submit_Job::instance()->get_job_id() );
            if ( wp_redirect( job_manager_get_permalink( 'job_dashboard' ) ) ) {
                exit;
            }
        },
        'view' => null,
    );
    return $steps;
}
@joewa1980

This comment has been minimized.

Copy link

joewa1980 commented Sep 7, 2018

Excellent! Many thanks.

@jom

This comment has been minimized.

Copy link

jom commented Feb 4, 2019

Replaced with https://gist.github.com/jom/749b818f9b388d37918b18d1bc1a6d15 for 1.32.0 compatibility.

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.