To create a seamless experience for the site users, you can use Toolset to create custom login pages.
You need to have the Toolset Access plugin installed in your site.
Create a template for the login form
When non-logged-in users reach the “My account” page, we want to provide a login form.
- Go to Toolset → Content Templates.
- Create a new template. Name it Login Form and don’t assign it to any post type.
- Add the Field and text block to this template.
- Click the Add Field or View button.
- Locate and click the Login form button.
- The Login Form dialog opens. Leave the default options and click to insert the shortcode.
You can’t get a preview of the form on the backend as it can only works from the front-end.
You will display this template to non-logged-in users instead of the “My Account” page.
Set the login form to appear only for visitors
Now, you need to configure the login form template to appear on the “My account” page for users that are not logged in.
- Navigate to Toolset → Toolset Access.
- Click the Post Groups tab.
- Click the Logged-in users only group.
- Click the pencil icon in the Guest row. A pop-up window opens.
- Select Show Content Template. Here, for users with restricted access, you can select a template to display instead of the page content.
- Choose Login Form, which is the name of the layout we just created.
- Click the Set errors button to save your changes.
- Save your post group.
Test the “My account” page for non-logged-in users
Visit your “My Account” page on the front-end as a non-logged-in user and you should see the login form.
Log into your site to test the form.
Insert the link to the “Lost password” page
To help users in case they forget their password, you can set up the “Lost password” page. Once you have it, simply link to it from the “My Account” page.
Hide pages from logged-in users
To complete our “My Account” page project, we offer one final suggestion. Some pages apply only to visitors, for example:
- Lost password
- Reset password
- Create account
It’s best to hide these pages from all logged-in users, thus making them available only for guests.
Use the following steps to accomplish this:
- Go to the Toolset → Access Control page and click the Posts Groups tab.
- Click Add Post Group and add those three pages to the group.
- Edit the group and make sure it is only available for Guest users.
Feel free to create a new template that will display for other users.
Hiding restricted pages from navigation
Please note that when you are hiding pages from some users by using Post Groups, they will also automatically disappear from your navigation.