Difference between revisions of "How to make part of theme visible only to registered users"
From JReviews Documentation
(2 intermediate revisions by the same user 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 in the theme files: | Use this code in the theme files: | ||
Line 13: | Line 19: | ||
</source> | </source> | ||
+ | If you need to make content visible to a specific user group(s), you can use the code below: | ||
+ | <source lang="php"> | ||
+ | <?php if ( $this->auth->belongsToGroups([1,2,3]) ) :?> | ||
+ | |||
+ | This user belongs to groups 1, 2 or 3 | ||
+ | |||
+ | <?php endif;?> | ||
+ | </source> | ||
Latest revision as of 23:55, 8 July 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;?>