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

From JReviews Documentation
Jump to: navigation, search
Line 17: Line 17:
 
<source lang="php">
 
<source lang="php">
 
<?php if ( $this->auth->belongsToGroups([1,2,3]) ) :?>
 
<?php if ( $this->auth->belongsToGroups([1,2,3]) ) :?>
 +
 
This user belongs to groups 1, 2 or 3
 
This user belongs to groups 1, 2 or 3
 +
 
<?php endif;?>
 
<?php endif;?>
 
</source>
 
</source>

Revision as of 16:02, 11 January 2020

Use this code in the theme files:

<?php if(!$this->auth->connected):?>
 
Register to View This Content
 
<?php else:?>
 
Content shown to registered users
 
<?php endif;?>

If you need to make content visible to a specific user group(s), you can use the code below:

<?php if ( $this->auth->belongsToGroups([1,2,3]) ) :?>
 
This user belongs to groups 1, 2 or 3
 
<?php endif;?>