Saturday, 22 September 2018

Redirect to a landing page after adding a new listing in Osclass

This code tested on Osclass 3.7.4
If you want to redirect to a static page after adding a new listing. You can get that result using the posted_item hook. in oc-content/themes/bender/functions.php
Example:
    function redirect_to_landing($item) {
        osc_get_static_page('example_page');
        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 example_page ( This is internal page name ) as a slug. So, remember that you will have to create first that static page.

If you want to redirect to a specific theme page after adding a new listing. You can get that result using the posted_item hook. Example:
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.