$core_v2_group.Current is returning site root group

I had assigned User1 to Group1 as member. When I call  $core_v2_group.Current it gives me Site Root group. How can I get the group where the logged-in user belongs to?

  • Users can belong to multiple groups.  To get a list of all the groups to which a user belongs, you can try something like this:  
    Disclaimer:  I wrote this code in the forum editor - not tested.

    #set($userGroups = $core_v2_group.List("%{ UserId = $core_v2_user.Accessing.Id}"))
    
    #foreach($group in $userGroups)
      $group.Name <br>
    #end

  • In reply to Luke D:

    And just to add $core_v2_group.Current gets the group you are currently on or is in context(mostly based on the page you are on).  It has nothing to do with membership

  • In reply to Patrick Mason:

    If you need to 'fetch all the users' or 'particular user' is/are member of 'particular group' then you can write logic as:

    #set($pagedListResponse = $core_v2_groupUserMember.List($groupId, "%{IncludeRoleMembers = $includeRoleMembersArg, MembershipType = $membershipTypeArg, PageIndex = $pageIndexArg, PageSize = $pageSizeArg, SortBy = $sortByArg, SortOrder = $sortOrderArg, UserId = $userIdArg}"))

    Otherwise if you need to 'find all the groups' of which 'particular user' is member of then you can write logic as:

    #set($pagedListResponse = $core_v2_groupUserMember.List("%{GroupId = $groupIdArg, IncludeRoleMembers = $includeRoleMembersArg, MembershipType = $membershipTypeArg, PageIndex = $pageIndexArg, PageSize = $pageSizeArg, SortBy = $sortByArg, SortOrder = $sortOrderArg, UserId = $userIdArg}"))

    You can fine more at this Reference Link and you can find more supported api here

    All this was based on Telligent 7.6 ; You can find code for other version of Telligent/Zimbra in community wikis.

    I hope it helps.

  • In reply to Harsh Baid:

    Thanks for all your reply. This helps alot.

Related