In SharePoint 2010, if you want to check logged in user exists which particular group using javascript as follow:
function IsGroupMember(GroupName)
{
var isGroupMember = false;
$().SPServices(
{
operation: "GetGroupCollectionFromUser",
userLoginName: $().SPServices.SPGetCurrentUser(),
async: false,completefunc: function(xData, Status)
{
if($(xData.responseXML).find("Group[Name='" + GroupName + "']").length == 1)
{
isGroupMember = true;
}
}
});
return isGroupMember;
}
The above code returns the Group name of the logged in user.
You can use this function as:
if(IsGroupMember("Human Resources"))
{
//your code comes here
}
0 comments:
Post a Comment