How To Use LoginPress With WooCommerce?

On the My Account of you, customers can see the default and boring login form, but if you have already designed an awesome login page with LoginPress that you want your customers to see on login.

Here is the scenario for the above situation:

  • Customer visit its “My Account” page, he will be redirected to your designed login page.
  • After logging in the customer will be redirected back to its “My Account” page and see its information as usual.

 

Here is what you need to do:

1) First, add the following snippet in your CSS in your theme’s functions.php file. This will make sure if the user is not logged in, he will go directly to the login page when landed to “My Account” page.

 

function loginpress_woo_login() {
if ( function_exists( 'is_account_page' ) ) {
  if ( ! is_user_logged_in() && is_account_page() ) {
    wp_redirect(wp_login_url());
    exit;
  }
}
}

add_action( 'wp', 'loginpress_woo_login' );

 

2) Now you need to set redirects for customers to go directly to their accounts page on login.

Here is where our “LoginPress Login Redirects” addon will come to action.

 

  • Got to your Login Redirects setting page
  • Choose Specific Roles tab.
  • Search your customer’s role i.e. “Customer”
  • Now add your “My Accounts” page URL in Login URL filed e.g www.mysite.com/my-account
  • Then add your desired logout page URL for customers in the Logout URL field, this can be your site landing page e.g www.mysite.com

 

This is it, all done.
Easy right! Now you can show off your awesome login page to your customers.

3 comments

Leave a comment

Your email address will not be published. Required fields are marked *

Blog
Articles