Page Access by Membership Type

3 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: May 31, 2016   (RSS)

By RGC - May 27, 2016

With regards to the Membership Manager Plugin - I have a list type radio button field called "type" with 3 options: customer, employee and accounting. Below is the code I used to restrict access to the page to members "type" equal to "accounting":

<?php require_once "../cm/lib/viewer_functions.php";
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
if ($CURRENT_USER['type'] == "customer") {redirectBrowserToURL('/customer/index.htm'); }
if ($CURRENT_USER['type'] == "employee") {redirectBrowserToURL('/index.htm'); }
?>

Although the code works, it is not logical to have to list each list type with a redirect if the type is other than "accounting".

I was hoping the code below would work, but it did not. Members with type "customer" can still view the page that should be restricted for member type "accounting" only.

<?php require_once "../cm/lib/viewer_functions.php";
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
if (!$CURRENT_USER['type'] == "accounting") {redirectBrowserToURL('/index.htm'); }
?>

Please advice how to best handle this.

Rod

By Damon - May 27, 2016

Hi Rodny,

Try this code:

<?php require_once "../cm/lib/viewer_functions.php"; 
if (!$CURRENT_USER) { websiteLogin_redirectToLogin(); }
if ($CURRENT_USER['type'] != "accounting") {redirectBrowserToURL('/index.htm'); }
?>

That should do it. Let me know if you need anything else.

Cheers,
Damon Edis - interactivetools.com

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

By RGC - May 31, 2016

Perfect .... That did the trick! Thanks

Rod