Difference between revisions of "How to make part of theme visible only to administrators"

From JReviews Documentation
Jump to: navigation, search
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
<div class="successbox" style="width: 95%">
 +
 +
[https://www.jreviews.com/docs/theme-resources/conditionals-based-on-user-authentication There's a new version of this article]
 +
 +
</div>
  
 
Use this code:
 
Use this code:
 +
 +
'''JReviews 2'''
  
 
<source lang="php">
 
<source lang="php">
<?php if($this->Access->isAdmin():?>
+
<?php if($this->Access->isAdmin()):?>
 
   // Everything here will be available only to admins
 
   // Everything here will be available only to admins
 
<?php endif;?>
 
<?php endif;?>
 
</source>
 
</source>
  
 +
'''JReviews 3'''
  
 +
<source lang="php">
 +
<?php if($this->auth->admin):?>
 +
  // Everything here will be available only to admins
 +
<?php endif;?>
 +
</source>
  
 
[[Category:JReviews]]
 
[[Category:JReviews]]
 
[[Category:Themes]]
 
[[Category:Themes]]
 
[[Category:Users]]
 
[[Category:Users]]

Latest revision as of 23:55, 8 July 2020

Use this code:

JReviews 2

<?php if($this->Access->isAdmin()):?>
   // Everything here will be available only to admins
<?php endif;?>

JReviews 3

<?php if($this->auth->admin):?>
   // Everything here will be available only to admins
<?php endif;?>