[groups_login] shortcode renders a login form, where the user can input the username and password to log in.
Here it is in its most simple form placed on a page as seen from the visual editor:
The form will appear if the visitor is not logged in.This shortcode allows the use of the following optional attributes:
redirectdefaults to the current URL and will redirect to the given page after successful login.
If you place the shortcode on a certain page and omit this parameter, a successful login will bring the user back to the same page where the login form is placed. If login fails due to a wrong username or password provided, the user will be taken to the standard WordPress login and once successfully authenticated, will be brought back to the page where the login form is placed.
If a URL is provided, the user will be redirected there after a successful login.
"no"and if set to
"yes"will present a logout link in place of the login form when the user is logged in.
This can be used instead of the
[groups_logout]shortcode if desired.
Here is a more complex example. You can place this snippet on a new page and view it first while logged in and then while logged out to see it as a normal visitor. The first section will show a text to those who are not logged in along with the login form. The second section would show some supposed links you could place there for members of a Premium group. The third section shows the link to log out.
Please log in to access our VIP sections:
Thanks for being a part of our community.
You have privileged access to these pages:
- Link 1
- Link 2