In this video we will show you how to design individual login pages with registration and login/logout forms and how to make content in the frontend available only for certain users.
How do I restrict access to content for certain visitors?
Hi, this is Sandra from GREYD and I’d like to show you today how to use GREYD.SUITE for gated content, thus content on your website that is only available to certain user groups like for example logged-in customers or employees with certain capabilities (e.g. with the user role “subscriber” or “contributor”. So what do we need for that? We need a custom login and logout page and we need special forms for the user registration and to log in and log out. So let’s start with the forms. I’ve already prepared a form here that I’d like to use for the user registration. In general these kind of forms work exactly the same like any other form on your website. You will find lots of tutorial on tutorials on GREYD.Forms in our Helpcenter. The only special block I’ve used here is the password block with two special options: The first one is the confirm password option with which you can make the user enter the password twice and you can also set certain password restrictions in terms of how long the password should be.
What we now need to do is tell the system that this is not a regular form that generates some kind of entry, but a form with which we would like new users to register. As soon as I select this option here, you will find that the settings up here will also change. So now we have to tell the system which kind of user role should be created when somebody registers via this form. You will not only be able to select the default WordPress user roles here, but if you’re using the GREYD.SUITE user management you will also find your custom user roles here and can then select form fields and assign them to your user role fields. You will need at least the username, email and password. Other than that you can also work with your custom user fields, that you might have created. What you will also find is that the email settings here have changed. You can edit the user registration email including the definition of where the user should be sent after confirming the registration. So that’s it for the form.
We will now move on with the custom login page. I’m now going to create a page with all my login/ logout and registration forms and thanks to Dynamic Content we can do all that on one and the same page as with conditional containers, different content can be shown on the same page depending on different parameters automatically. If you want to learn more about that in general please have a look at our Helpcenter where you will find a very helpful tutorial video. So the login and registration forms will only be necessary for those users who are not already logged-in. I’ve just placed a conditional container here and will now define the condition dependent on the user role. The contents only apply to those that are not yet logged-in. Now we are going to place some content here, do some basic stylings…
And here I’m now going to place my just created registration form. And here I am going to place a login form. You could either work with the default WordPress login or also work with the GREYD.SUITE version that comes with two handy additional options: One is the redirect URL. You can define where a user should be redirected after a successful login. And you can have a remember me checkbox that saves the login details via cookie so they are saved for the next visit.
So that’s it for non-logged-in users. Now we need a another conditional container for those users that are logged-in. So let’s just change that here, user role is “not unknown” and we can work with the same login form as it will automatically display a logout for those users who are already logged-in. And what I’m also going to do now is greet the user by name. That works with dynamic tags. You’ll also find a tutorial video on that. It’s just a nice little add-on here. Let’s publish the page and let’s just do some settings to make it easier to show the result.
Let’s now view the page. So, I’m currently logged-in. So I’m greeted by name and I have the logout link and also a link to the website administration as I am an admin. And if I now log out, I will automatically be displayed my registration form and the login form. One last thing I’d like to share with you: You can also prevent users from being able to see pages or also posts at all. There’s a nice option in the page or post settings down here, where it says “exclude this post for certain users” and here I could for example decide that editors should not be able to access that page at all in the frontend. So whenever a logged-in editor tries to access the login/logout page, he or she will be shown the 404 page instead.
For more videos and information please visit our Helpcenter.
Was this article helpful?