• Resolved jaikrmandal

    (@jaikrmandal)


    Hi, Please Explain i want to Redirect woocommerce My account to login page If user not logged in .
    Example- I give user links of my order or my wallet(tera wallet)option in Menu so when you clicked it will land you in woocommerce login page. I need to land a costume login page. Remember this condition i want to use if user not logged in.
    Please Support and help. If I don’t want to use login page of woocommerce.

Viewing 1 replies (of 1 total)
  • Plugin Contributor Niels Lange

    (@nielslange)

    Hello @jaikrmandal,

    Thanks for reaching out to us! I looked into this case and created the following code snippet:

    /* Redirect non-logged in users from the My Account page to the Login form. */
    function redirect_to_login() {
      if ( is_account_page() &&  ! is_user_logged_in() ) {
        wp_redirect(wp_login_url());
        exit;
      }
    }
    add_action( 'template_redirect', 'redirect_to_login' );

    You can add this to your site using the Code Snippets plugin. Please note that we usually don’t create custom code snippets. Given that this is a fairly simply code snippet, I made an exception, though. Please also note that this code snippet does exactly what you asked for: It redirects non-logged in users, that try to access the My Account page to the WordPress login form. This might not be what a customer expects to see.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirect woocommerce My account’ is closed to new replies.