*

pipetko

  • *
  • 34 posts
Redirecting to the ad after posting
« on: August 05, 2020, 10:06:42 AM »
If you want to redirect after an user post ad to the ad directly, here is the solution
Got help from another forum but it is usefull.

To redirect after posting, put in your functions.php file of theme this code:
Code: [Select]
if (!function_exists('bender_redirect_to_item')) {
    function bender_redirect_to_item($item) {
        if ($item) {
            View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($item['pk_i_id']));
            osc_redirect_to(osc_item_url());
        }
    }
    osc_add_hook('posted_item', 'bender_redirect_to_item');
}
Replace bender_ by prefix of theme that you have using.

Example with code for veronica theme:

Code: [Select]
if (!function_exists('veronika_redirect_to_item')) {
    function veronika_redirect_to_item($item) {
        if ($item) {
            View::newInstance()->_exportVariableToView("item", Item::newInstance()->findByPrimaryKey($item['pk_i_id']));
            osc_redirect_to(osc_item_url());
        }
    }
    osc_add_hook('posted_item', 'veronika_redirect_to_item');
}