All posts by admin

woocommerce force login before checkout

add_action(‘template_redirect’,’check_if_logged_in’); function check_if_logged_in() { $pageid = 56; // your checkout page id if(!is_user_logged_in() && is_page($pageid)) { $url = add_query_arg( ‘redirect_to’, get_permalink($pagid), site_url(‘/signin/’) // your my acount url ); wp_redirect($url); exit; } if(is_user_logged_in()) { if(is_page(831))//my-account page id { $redirect = $_GET[‘redirect_to’]; if (isset($redirect)) { echo ‘<script>window.location.href = “‘.$redirect.’”;</script>’; } } } }