Isse with a user forwarding function in Wordpress

Viewed 11

I have created this code for my Wordpress Theme's function.php file. I want to redirect the user to certain URL if they are on a certain page.

Please check if this function is correct? The code is working, but it's creating an error with Woocommerce checkout and not letting customer place an order.

function user_login_check()
{
    if (is_user_logged_in()) {
        if (is_page(123)) {
            wp_redirect('https://example.com/alpha');
            exit; 
        };
        if (is_page(456)) {
            wp_redirect('https://example.com/beta');
            exit; 
        }
    }
}
add_action('wp', 'user_login_check');
0 Answers
Related