Skip to content

Instantly share code, notes, and snippets.

@davoraltman
Last active February 28, 2021 03:55
Show Gist options
  • Save davoraltman/d6bfef30bcfa689ff2922ec13d38ff46 to your computer and use it in GitHub Desktop.
Save davoraltman/d6bfef30bcfa689ff2922ec13d38ff46 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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
Copy link

Excellent! Many thanks.

@jom
Copy link

jom commented Feb 4, 2019

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

@datdudejibril
Copy link

Code doesn't work if you're using the WC Paid Listings plugin per this topic: https://wordpress.org/support/topic/redirect-to-dashboard-after-job-submission/

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