EnjoySharePoint YouTube Channel

SharePoint Online Check current user belongs to a particular SharePoint group using JavaScript object model

In this post, we will discuss how we can check if the current logged in user belongs to a particular SharePoint group using JavaScript object model. Here I have a SharePoint group as “Team Site Owners” where I am checking is the current user belongs to the particular group or not.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

Also you can see:
Create Content Type using JavaScript object model in SharePoint Online Office 365

How to get alternate languages from language settings in SharePoint online using Rest API?

Add use custom action to list ECB menu in SharePoint Online using JavaScript object model

I have put the below JavaScript code inside a script editor web part.

<input id=”btnCheckUserCurrentGroup” onclick=”CheckCurrentUserBelongstoGroup()” type=”button” value=”Check current user belongs to group” />

<script src=”https://code.jquery.com/jquery-1.10.2.min.js” type=”text/javascript”></script>

<script type=”text/javascript”>

var userGroups;

function CheckCurrentUserBelongstoGroup()


var clientContext = new SP.ClientContext.get_current();

this.currentUser = clientContext.get_web().get_currentUser();


userGroups = this.currentUser.get_groups();




function OnQuerySucceeded() {

var isMember = false;

var groupsEnumerator = userGroups.getEnumerator();

while (groupsEnumerator.moveNext()) {

var group= groupsEnumerator.get_current();

if(group.get_title() == “Team Site Owners”) {

isMember = true;






function OnQueryFailed() {

alert(‘Error occured’);



Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →