@PitaJ Thank you, nice!
Check if user is in group
Moved
Technical Support
-
Hey there! So, I've been customizing a theme lately, and I was wondering if there was a way to check if a user is in a group, for example:
<!-- IF user.groups.admin -->
, or perhaps even with JavaScript. I'd like to be able to add extra content to a user's profile if they are in a certain group, (for example, perhaps admins could have a special image on their profile).Please let me know if there's any way of doing this, thank you!
EDIT: Or even being able to do this per-user would be absolutely fine for me! Thanks again.
-
-
- Notice the hook listener registered here: https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/plugin.json#L7
- Corresponding to a method in the plugin library itself: https://github.com/NodeBB/nodebb-plugin-quickstart/blob/master/library.js#L7
You'll want to listen to the hook I mentioned above, and make a call to
groups.isMember()
to check group membership status, and then save it to the corresponding users' information.