Jump to content

hook to redirect incoming URLs based on $_GET parameters


Recommended Posts

I'm trying to write a hook that will redirect to the proper cart gid.

The inbound URL will look like https://mywhmcs.com/cart.php?prod=2.03

I want to redirect that to https://mywhmcs.com/cart.php?gid=2

 . . . some idea of the many things I've attempted

add_hook('ClientAreaPageCart', 1, function ($vars)
{
    if ($_GET($vars['prod']) === '2.03'){
        return $base_url . '/gid=2';
    }
});

 

Thanks for any help.

Link to comment
Share on other sites

This works, but I'm not sure there isn't a better way to redirect to the URL (doesn't the constant WEB_ROOT work?).

 

add_hook('ClientAreaPageCart', 1, function ($vars){

    if ($_GET["product"] === 2.03){
        $url =  '/cart.php?gid=2';

        while (ob_get_status()) {
            ob_end_clean();
        }

        header( "Location: $url" );

    }
});

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated