Site icon Hip-Hop Website Design and Development

WooCommerce Registration redirect based mostly on web page ID

I’m attempting to vary the WooCommerce Registration button redirect hyperlink. That is the code I take advantage of for the redirect (which works simply tremendous):

operate custom_registration_redirect() {
        if(is_user_logged_in()) {
            return home_url('/checkout/');
        }
    }

add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);

The problem is: I would like to vary the redirect based mostly on the web page the person is definitely on, so I attempted doing this:

add_action('wp', 'page_check');
operate page_check() {
if (is_page(29179)) {
    operate custom_registration_redirect() {
        if(is_user_logged_in()) {
            return home_url('/checkout/');
        }
    }
    add_action('woocommerce_registration_redirect', 'custom_registration_redirect', 2);
}

however for some cause it does not work… I do know I am most likely lacking one thing right here however I do not know what…

Thanks upfront in your assist! 🙂