I have the following code:
<?php if ($user->id >= 1): // logged in ?>
This checks to see if the user is logged in, but not which group the user belongs to. I'm trying to show content only for registered users.
Joomla Stack Exchange is a question and answer site for Joomla! administrators, users, developers and designers. It only takes a minute to sign up.Sign up to join this community
Resolved with the following code:
I just needed to discover a way of grabbing either the group name or user group id.
We do the latter and grab the id of the group we wish to manipulate. All user group ids of the current user are added to an array ($groups). Then we search that array for the group id we need.
$user = JFactory::getUser(); $groups = $user->get('groups'); if (in_array(2, $groups))
A quick search turns up a couple of answers that give you a list of groups the user belongs to that you can then process to determine if the group is the Registered group.
This answer is for J2.5 but still looks like it will work. https://stackoverflow.com/questions/18407595/get-user-group-id-in-joomla-with-php/18407692
This answer is more comprehensive and should be enough for you to progress. How to know which usergroup/specific access level user belongs to