I have found this code that after adding an item to cart, if the customer isn’t logged in they are redirected to a login page. At the moment I am getting an error, I think I haven’t edited the code properly.
function wpse_131562_redirect() {
if (
! is_user_logged_in()
&& (is_cart() || is_checkout())
) {
// feel free to customize the following line to suit your needs
wp_redirect('myshop.co.uk/sign-in'());
exit;
}
}
add_action('template_redirect', 'wpse_131562_redirect');
2
Answers
Yes, the function wp_redirect is wrong.
wp_redirect( 'https://myshop.co.uk/sign-in' );
should do the jobWithout https:// it is giving error. you should use home url dynamic try the following code