Return Group Name of Specified Member
Posted
#3700
(In Topic #739)
{$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
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.
Posted
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
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.
2 guests and 0 members have recently viewed this.