Redirect to a landing page after adding a new listing

In certain cases, you want to redirect to a specific page after adding a new listing. You can get that result using the posted_item hook. Example:

    function redirect_to_landing($item) {
        osc_get_static_page('publish_ok');
        header('Location: ' . osc_static_page_url()); exit;
    }
    osc_add_hook('posted_item', 'redirect_to_landing');
    // add this code in the functions.php of your theme

The code from above would redirect to a static page that has publish_ok as a slug. So, remember that you will have to create first that static page.

The next example will redirect to the listing page:

    function redirect_to_landing($item) {
        View::newInstance()->_exportVariableToView('item', $item);
        header('Location: ' . osc_item_url()); exit;
    }
    osc_add_hook('posted_item', 'redirect_to_landing');
    // add this code in the functions.php of your theme

The hook posted_item it’s available since the version 2.0.