-
Notifications
You must be signed in to change notification settings - Fork 129
Added {exp:member:role_groups} template tag #3702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added {exp:member:role_groups} template tag #3702
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swierczek I think it's good addition! We're planning to roll out some Member functionality updates in 7.4, so it might go there as well.
I added a couple of comments, and also the code needs to be made PSR-12 compatible (e.g. a space is needed after foreach)
} | ||
|
||
$vars = []; | ||
foreach($member->RoleGroups->asArray() as $roleGroup) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific reason to call asArray
here? RoleGroups
is already iterable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, I didn't realize it was iterable 👍
]; | ||
}; | ||
|
||
if (!$vars) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting array to boolean is not PHP-version-proof. It should be better to use empty()
check instead
]; | ||
}; | ||
|
||
if (!empty($vars)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be inverted - fixed here: f8bf5ac
It appears that besides member roles assigned to groups, role groups can be assigned directly to members (don't ask me why! :) - although you can't assign those directly to superadmins. The template code was only respecting the second, and not the first - so I added that. @matthewjohns0n please re-test |
Add
{exp:member:role_groups}
template tag to get info about which Role Groups a member is assigned to.Documentation will still be needed if this is accepted, which I am happy to update too. I didn't want to do all of the work if this will be declined by the mods though.
Demo template:
Output for member not assigned to any Role Groups:

Output for member in a Role Group:
