Hide Content for Non Register Users | Wordpress Plugin Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we're going to see how we can restrict content from our website if the visitor is not logged in hi my name is stratos and i'm constantly producing video tutorials about wordpress please subscribe to my channel for more videos like this also please take a moment give me a thumbs up and help me grow my channel so we're going to install plugin and we're going to show or hide content in our website based on the user if he's logged in or not this is the website that we're going to use it's an astra free template and as you can see it has the home it has a services page it has an about us page and also a contact page we're going to hide the about us page it's not just removing from the menu because if someone has the url he can also access it but we're going to hide it for all the users that are not subscribed so what we're going to do first is going to install a plugin let's go into the plugins let's go into the add new and here we're going to type members there are many plugins that can restrict content from your website and also they can do much more than that but we're going to see a very simple plugin that can do exactly that we're going to use this plugin restrict user access and we're going to install that now and after that we're going to activate the plugin okay let's go and hit skip and now here is the menu that we have for the user access i have also opened an incognito window and this is because i want a session which i'm not logged in so we're going to see what the visitors can see as you can see i'm going to hit the about us page and this is the page that we're going to hide so let's go back to the website and here we're going first to create an access level now what is an access level basically you create some levels that you want to have and then you go into the pages and select the levels that you want to set those for and after that you can add as many users as you want inside those levels and the levels will handle the content so let's go first and add a new one i'm going to trust this because that was from my test and let's create a new one and here you can put whatever name you want you can put just subscriber or not visitors or not whatever you want to put keep in mind that this plugin cannot handle payments you have to use another plugins for all of that this is basically for restricting the content from your website so we're going to create something like subscribers and here we're going to create the new condition group i'm going to click here and here i can specify what i want to hide from the website if you want you have the special pages that you can select author pages page templates then we have the post types we have pages media and we have the categories tags and formats for me it's going to be pages and then inside the pages i'm going to select the about us page about us page now i'm going to go into the second tab which is the members here once i click here i can select the automation which is better but i have tested and it's working fine and here i'm going to create something to automate when new users are going to subscribe to the website that are going to be set automatically in this level so i'm going to hit add i'm going to hit user role and then i'm going to select the subscribers whenever a user is going to subscribe to the website he was going to have access to this level of course you can use another plugin create some user roles and then have other levels as well and do more automations like this let's go into the next one which is the capabilities and here you can set features that you want to have in those levels i'm not going to mess any of this up and then you can go into the options here in the options we're going to select the extend level and as you can see this is where you can select what you want to do when an unsubscriber tries to access that page of course we're going to hide it from the menu but if someone has already saved the url you want to do something when a user is going to access that page so we're going to redirect him and we're going to create a different page to redirect him to this is the duration and this is the duration of course of the level so we're going to select uh six months let's get let's go for six months so whenever a user is subscribed he's going into the subscribers access level and he's going to stay there for six months can he access unrestricted content yes he can and if you want to hide the admin bar this is the admin bar up on top where you're going to do it from here after that you can create and now the next thing is going to create a page that we're going to redirect to it's going to be a simple page and let's go into the pages let's go and add new let's go here and the name of the page will be register now so let's create a register now page and here you can type something like you're trying to see a restricted content from the website please subscribe to the website in order to see the content this is the page that i'm going to show i'm going to publish that and i'm going to publish that again and now i have the page that i want let's go back to the edit level and here i can select here and i'm going to redirect and then i can select here and select the register now as you can see i don't have to refresh here it grabbed automatically the page that i've created let's go and hit save now so now i have restrict the about us page and only show that to the subscribers of the website let's go and see the page at the moment and now i can see the page because i'm the administrator of the website but if i go into the incognito mode here and refresh i can no longer see the about us page as you can see the about us page went away and now i'm going to view the register now you're trying to access the register content so even if i had the url i couldn't access the page let's go now to the previous one here let's go to the website i'm going into the appearances i'm going to the menu and now i want to hide the pages from the non-registered users so let's go into the about about page and here i'm going to search for levels and i'm going to select subscribers after that let's save the menu and if i go into the incognito mode and refresh i'm going to see that the about us page is going to be hidden so now i have successfully hide the page that i want you can do the same thing and hide the posts or whatever content you want to hide keep in mind that you should go into the pages that you are restricting and select a no follow for the search engines so they will not crawl the pages that you don't want them to see now the thing that i want to do now is create another form so the users can register in the website so what i'm going to do is install another plugin let's go and add a plugin and we're going to use a form plugin for that there are many plugins that can do the same thing again and i'm going to use here the forminator let's install that as you can see it has over 200 000 active installations let's hit activate and now here i'm going to click deforminator i'm going to click forms and here i'm going to create a form i'm going to select the registration i'm going to select continue and then create now as you can see i have the fields that i want the username email and the password those are the three fields that are necessary in order for someone to register you can also add fields for the name if you want for the last name and also you can select the password and if you want you can edit that and select to confirm password so the user have to set the password twice in order to be sure that he has said it correctly so i'm going to do that and i'm going to go the appearances here i'm going to click the user registration because i don't want to change that here you can map the fields that you have created in the form with the actual fields inside the wordpress core so we have the username which takes the username field the email from the email field the first name we don't have any field to select from the form here if you have already created the last name field you can selected that here the website field is here we don't have any inside our forms and this is the password after that it says that the new users will be subscribers so i'm going for that subscriber and then i'm going to select the behavior here it says if you want to change the message that it will say account research successfully click here to log into your account i'm not going to change any of that i'm going to go into the mail notification and this is the email that the visitor is going to take about his registration let's go into the integrations of course we don't have any integration in style you have to go into the integration here to activate something and then go into the settings if you want to change any of these i'm not going to so let's go and publish that and here is going to give us the codes so this is the shortcode for the registration form i'm going to copy that and let's go into the page that we have created that says register now and here i'm going to go and paste here the shortcode so i'm going to type shortcode just to add the shortcode and here you can paste the shortcode also you could create something like two columns here create another form which will be the sign in form with the same plugin deforminator and have the first form here with the title like register now or sign in now if you want to sign in for those that have already registered in the website let's go and update that and now we can view the page and we're going to see that at this moment we are already logged in so there's no point for us to register i'm going to copy the url i'm going inside the incognito mode and i'm going to paste that in here now as you can see this is the register now and this is the form that we have created so i'm going for the username this is the test1 then email test at test.com then the password is something okay and then i'm going to hit register after that it's going to say that this is successful registration account successfully registered and now you can log in here so i'm going to click here and i'm going to logged in test1 and then for the password is this one okay login and now if i go to the front end i'm going to see the about as normal and i can see also the content of the about us page if i go back to the website i'm going into the plugin the user access and let's go to the access levels and here i'm going to see that i have the subscribers with one member i can select the one member here and it's going to go into the members here as you can see and i have a test one member that says it's active it's since 42 seconds ago and it will expired in six months also if you go to the users and if you go to all users you will see here the test one which is already for the access level subscribers so everything worked fine so this is the simplest way that you can hide content based if a user is logged in or not if you want to handle payments as well then you have to use another plugin so if you have any questions please leave it in the comment below give me a thumbs up if you liked the video and i will see you all in the next one bye guys
Info
Channel: Stratos Tutorials
Views: 645
Rating: undefined out of 5
Keywords:
Id: 3CLCdfOW6hY
Channel Id: undefined
Length: 12min 24sec (744 seconds)
Published: Mon Oct 04 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.