How to add/edit user roles and accessing hidden content.

Gewijzigd op Thu, 12 Jan 2023 om 11:01 AM

First of all, what are users and user roles ? Users are identifications used to login or register on a website. User roles are the roles those users get assigned during the registration process. 

In wordpress, new registered users get the role "subscriber" per default, which is the most basic role a user can get. But, if you want to make a user be able to have access to more info on the website, or You want to grant him access to hidden or specific files you can use a role editor, which is what we'll be seeing here.


Plugin used : Members plugin
                      SysBasics


Pre-requirements :

  1. the user you want to edit needs to be registered or subscribed.

       2. In this tutorial, "Subscriber" and "Customer" user roles are the same.



1- Login and go to the dashboard, then on the left click on members.



2- In the members tab, you have the option to add a new role, edit an existing one or delete those. 

   

For this tutorial, we will use cloning or duplicating of an existing role. (I always advice doing this).


If we want to create a user role who has access to most part of the website but not the most crucial part, the "editor" role is advised. It's the role that follows the administrator role (which is the highest role).


We can also clone the "subscriber" role and increase its roles (this is best for customers/agents that want to have access to a specific page or content which is normally hidden to simple subscribers.


3- We will create a "KBC agent" role who has subscription level access (cloned from a subscriber/customer role).


Click on "clone"

You'll be prompted to a cloned page .

  • Rename the role to what you want, from "customer kloon " to something like "special customer". ( In my case it will be KBC agent).
  • Grant access or deny access to the specif main contents available on your wordpress website. You can do so by ticking or unticking the boxes on the right of each panel.(In my case I won't change anything else because i want this role to have the exact role as a subscriber/customer).
  • Once you're done click on save/publish role, located on the top-right (Rol toevoegen). If you don't save, the user role will not be created.


4- Like i explained in the Intro, new registered users get the role "subscriber" per default. So in order to make sure that our newly created user role get assigned to someone, we have to do it manually.

  • click on the "Users" tab and search for the user to assign the new role to.(In my case its ionutloghin)
  • Then click on edit



Scroll all the way down , and tick the role you want to assign him to. then click "update user". You can also untick the previous role he had (this is optional, because you may want this user to get multiple roles).



How do i make this specifc user role to be able to only access a specific page ?


To be able to access a specifc page, first go to the "pages" tab and search for the page you want to show to only specific user roles. 

If the page is not yet created, click on the "Add new" button and create a new page. (In my case i created a new page called KBC Agent).

If the page already exist, click the "edit" button beneath the page link


When you opened the page scroll to the last section of the page and select which user role will be granted access to this page. 

Only the user role that are checked will be able to view this page after they login. If a user isn't assigned this user role or is not logged in, he will not be able to see this page.





Customize the "My Account" page


When logged in, click on the "dashboard user icon" on the top right to access your account page.


In this page you have access to specific blocs like orders, account details, quotes and wishlist.

The blocs can be deleted and edited in the backend, AND you can also directly add the hidden page you want from here (of course only those who have access to it will visually see this).




To edit those blocs, Head to the backend and click on "SysBasics" .


Per default the first 5 blocks you see in the image are available. You can tick or untick the associated boxes, depending on the blocs you want to see or not see respectively. 


In this case, only 3 blocs are choosen to show on the user's dashboard. 


We decided to add another bloc called KBC agent, which is link to the "kbc agent page". 

To add that, you click on "Add link".


When you click on"add link", you'll be asked to choose a title for the bloc/link. DO so and save.


Then click on the menu icon next to the newly created bloc/link.


You can then select which role will have access to this bloc. Save after all is done.


As you can see in the pictures below, Depending on whether or not a user role was selected to show, it will be visible or not.





Good to know



  1. Just in case someone has access to the link to that hidden page, he will be prompted with a custom message chosen by yourself.


To know where to edit this, Hover over the Members tab and choose settings. From there you'll be able to add/edit a customised message.




Was dit artikel nuttig?

Dat is fantastisch!

Hartelijk dank voor uw beoordeling

Sorry dat we u niet konden helpen

Hartelijk dank voor uw beoordeling

Laat ons weten hoe we dit artikel kunnen verbeteren!

Selecteer tenminste een van de redenen

Feedback verzonden

We stellen uw moeite op prijs en zullen proberen het artikel te verbeteren