How to get the direct group names for an user?

Certified Senior Developer

Is there a way to get the group names by passing the user name who are the direct users of that groups.

Example:

Parent Group: Group 1, Child Group:Group 2

Group 1:(user A, user B), Group 2:(user c)

If I pass user c, the result should be Group 2.

getgroupsformemberuser() returns all the groups irrespective of direct or indirect membership

  Discussion posts and replies are publicly visible

Parents Reply Children
No Data