Get Current Logged-in User Group Collection Using SPServices JQuery Library

The $().SPServices JavaScript Add-on provide the function $().SPServices. GetGroupCollectionFromUser, which will help to get details of all groups belongs to current logged-in user in the SharePoint site.

Get current logged-in user group collection using $().SPServices.GetGroupCollectionFromUser:

var userGroups = [];
$().SPServices({
    operation: "GetGroupCollectionFromUser",
    async: false,
    userLoginName: 'i:0#.f|membership|amitkumar@amitkumarmca04.blogspot.com',
    completefunc: function  (xData, Status) {
 
        $(xData.responseXML).find("Group").each(function () {
            userGroups.push($(this).attr("Name"));
        });
    }
});
console.log(userGroups);

In the above code block, I am passing the login name of particular user to get user group collection. We can also use $().SPServices.SPGetCurrentUser() to get the user group collection of current logged-in user.