Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder: Plugins & Add-ons:
Website Membership Plugin - Restrict Access based on Access Level

 

 


cKopyar
User

Jul 7, 2011, 8:36 PM

Post #1 of 3 (840 views)
Shortcut
Website Membership Plugin - Restrict Access based on Access Level Can't Post

I am using the Website Membership Plugin. I have successfully integrated it into my site to restrict certain pages. I have one page that I want to restrict based on user level. For example, is a user is an Editor or an Admin, I want them to be able to see this page. Otherwise, I do now want the page (or it at the very least it's content) to be visible. I want to either display a message on the page that says you don't have access to this page, or redirect them. I am sure this is simple to do. Suggestions?


Jason
Staff / Moderator


Jul 8, 2011, 9:46 AM

Post #2 of 3 (812 views)
Shortcut
Re: [cKopyar] Website Membership Plugin - Restrict Access based on Access Level [In reply to] Can't Post

Hi,

There are a couple of ways of doing this depending on how you are setting up your user levels. If you're using the section access list inside the accounts section, here are a couple of things you can check for inside the $CURRENT_USER array.

You can check the "isAdmin" field to see if they have administrative access and take action if they don't:


Code
<?php if (!$CURRENT_USER['isAdmin']): ?> 
.. code for what to do if they are not an admin.
<?php end if ?>


If you want to check to other user levels, you can look at the 'accessList' field. This is an array inside the $CURRENT_USER variable that uses the name of the section as a key and has a field called "accessLevel" which stores a number.

For example, if you're checking to see if a user has editor access to all sections, and take action if they don't, you can try this:


Code
<?php if ($CURRENT_USER['accessList']['all']['accessLevel'] != 9): ?> 
.. code for what to do if the user doesn't have editor access to "all" sections.
<?php endif ?>

For accessLevel, none = 0, author = 6, and editor = 9

Hope this helps get you started. Let me know if you have any other questions.

---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/ 


cKopyar
User

Jul 10, 2011, 3:30 PM

Post #3 of 3 (758 views)
Shortcut
Re: [Jason] Website Membership Plugin - Restrict Access based on Access Level [In reply to] Can't Post

I was able to get this working. Thanks