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.

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.

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.

joewa1980 commented Sep 7, 2018

Excellent! Many thanks.

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