Return Group Name of Specified Member
Posted
#3745
(In Topic #736)

Standard member

{$GROUP_ID}, despite what it says in the Composr docs, doesn't seem to support any parameters here. It returns empty when including a parameter and only returns the ID number of the current members usergroup when no parameters are supplied.
{$GROUP_NAME}, also doesn't seem to support any parameters. This identifier also returns empty when supplying a parameter, and returns the name of the current members usergroup when no parameter is given.
My hope was to supply the username or member-ID as a parameter to return the name of the group that user is in. The documentation describes this as possible, or at least this is my understanding.
{$IS_IN_GROUP} won't work because I'd need to be able to supply the username or member-ID, but any parameters entered here are considered as group-ID's. Using additional parameters only specify a list of group-ID's.
Posted

Standard member

parameter1 = the nth usergroup a member is assigned to for which you want the usergroup name. A parameter value of 0 should return the primary usergroup. A parameter of 1 should return the first secondary usergroup name, 2 should return the second secondary usergroup name, etc. If omitted, it defaults to 0.
parameter2 = the member ID # of the member you want to lookup. If omitted, it defaults to the member ID # of current user viewing the page.
The GROUP_NAME symbol works with member ID #. There may be some complex set of tempcode that might make it work with a username. If not, the GROUP_NAME tempcode symbol could be rewritten as a new tempcode symbol to give you a primary usergroup name using a username as a parameter.
Regards,
Jason
My ocPortal Sites: Holleywood Studio / Tech Fusion Online
My Composr Sites: NEWBotics Labs
Jason
My ocPortal Sites: Holleywood Studio / Tech Fusion Online
My Composr Sites: NEWBotics Labs
Posted

Standard member

Your advice worked. But maybe we can get Chris to edit the documentation to show the use of multiple parameters for this Tempcode identifier.

Posted

Site director

Yes, the docs were wrong. Both GROUP_ID and GROUP_NAME take a value 'n' as the first parameter, where n is the group sequence number counting from 0. Where 0 is the primary group.
Then the next parameter is the member ID, defaulting to the current member.
Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon
- If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
- If so, please let others know about Composr whenever you see the opportunity or support me on Patreon.
- If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying Composr on fun personal projects.
- If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
1 guest and 0 members have just viewed this.