Displaying content to Admin, Editors and Authors on the front-end of site.

6 posts by 2 authors in: Forums > CMS Builder
Last Post: January 27, 2016   (RSS)

By Mikey - January 21, 2016

I need to display content on a site page only to site admin(s) and editor(s)... I've tried a few scenarios but I'm just not getting it.

Here's basically what I'm trying to do... but this code does not work.

<?php if($CURRENT_USER['isAdmin']) : ?> 
Display Admin Message / Content
<?php endif; ?>

<?php if($CURRENT_USER['accessLevel'] == 9 ) : ?> 
Display Editor Message / Content
<?php endif; ?>

<?php if($CURRENT_USER['accessLevel'] == 6 ) : ?> 
Display Author Message / Content
<?php endif; ?>

Anyone have any suggestions? Thanks, Zicky

By Damon - January 22, 2016

Hi Zicky,

$CURRENT_USER is  only available if you are using the Website Membership plugin. To get the current logged in user details in CMS Builder without using the Website Membership plugin, add this code above your code. I'm using $CMSB_USER as an example. You can name it anything you want.

$CMSB_USER = getCurrentUserFromCMS(); 

Now if you use the showme function you will see all the current variables and data available to use and compare:

<?php showme($CMSB_USER); ?>

Hope this helps!

Cheers,
Damon Edis - interactivetools.com

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

By Mikey - January 22, 2016

Hey Damon,

Thanks for the code snippet... very useful.

I think I may not have explained myself well enough, or I'm not understanding something in your reply.

So what I'm trying to do is figure out the php code to display on a webpage - content based on the site manger's permissions.

So an Admin would see one  type of Message / Content
An Editor would see another type of Message / Content
And an Author would see another type of Message / Content

all based on their "accounts" permissions.

Thanks, Zicky

By Mikey - January 27, 2016

Hey Damon,

Thanks for the help. Does the trick!

By chance is there any way to perform a function "By Section" permissions?  OR if there's a better way to do this. Basically I would like to display content on a page based on the user's "By Section" permissions to access specific section editors and their perspective site pages.  The code below wouldn't work, but hopefully you'll get were I'm going with this. 

<?php if($accessLevel == by section ) : ?>
   Display Author Message / Content <br />
<?php endif; ?>

Thanks Zick

By Damon - January 27, 2016

Hi Zicky,

Check out the code Jerry and I worked on together to create a page that displays all the user access by table (by section) and the access level for each:

http://www.interactivetools.com/forum/forum-posts.php?postNum=2237472#post2237472

Not exactly what you are after but you could repurpose the code.

Let me know what you think.

Cheers,
Damon Edis - interactivetools.com

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