Forum Discussion

dhiraj_gophane's avatar
11 years ago

Rest API to get the groups available to current user

Hi all,

How can I get list of groups that are accessible to current logged in user.

Is there any direct API which will give us the groups which user can access.

 

The list should contain:

 

1) all open groups

2) all groups to which a user is already connected.

 

 

Hoping to see the solution asap.

  • AdamN's avatar
    AdamN
    11 years ago

    If you're not seeing any groups, I'd suggest double checking your default permissions for groups to ensure that users have access to see and join groups. You might also want to check to make sure that there isn't any code in your custom component that would be wrapping the REST call and preventing it from occuring (i.e. some other permission/role check you may have added).

     

    One way to do a quick check to see if it's a permission issue vs something with your component would be to create a separate test component and add this snippet:

    <#list rest("/groups/list").groups.group as group>
    ${group.id},
    </#list>

    You could even add it to an announcements section temporarily if you didn't want to create a separate component. If you login as a regular user and view the page this code is on, you should see a list of Group IDs. If you don't, it's likely a permission issue. If you do see it, there's likely an issue with your custom component.

    • Hi Adam,
      Currently I am using this API only.
      It gives me groups in context with the current node.
      I want list of groups in context with the current logged in user.
      • AdamN's avatar
        AdamN
        Khoros Oracle

        If you're making the REST API call as the user you're interested in, it should respect the permissions and settings you've configured for each group and only show the user the groups that the user has access to. Is it not behaving as you'd expect?

         

        Perhaps I'm misunderstanding what you're interested in. Would it be possible for you to give an example of what you're trying to accomplish, and the shortcomings of the method I suggested?