Getting a Group List for a Member

Users can get a list of groups that they are a member of.

The following sample code shows how to get a list of groups that the current user is a member of.

  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Get a list of groups that the current user is a member of.
    user.memberOfGroups().then(
      function(params) {
        var theUser = params[0];
        var groupList = params[1];
        for(var i = 0; i < groupList.length; i++) {
          var g = groupList[i];
          // Do something.
        }
      }
    ).catch(
      function(error) {
        var theUser = error.target;
        var errorString = error.message;
        // Handle the error.
      }
    );
  • // Get the currently logged-in user.
    var user = KiiUser.getCurrentUser();
    
    // Get a list of groups that the current user is a member of.
    user.memberOfGroups({
      success: function(theUser, groupList) {
        for(var i = 0; i < groupList.length; i++) {
          var g = groupList[i];
          // Do something.
        }
      },
      failure: function(theUser, errorString) {
        // Handle the error.
      }
    });