Monday, 15 June 2015

Check if current user is in a specified group Using SPServices

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js”></script>
 
<script type=”text/javascript” src=”http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js”></script>
 
<script type=”text/javascript”>
 
$(document).ready(function () {
 
$().SPServices({
 
operation: “GetGroupCollectionFromUser”,
 
userLoginName: $().SPServices.SPGetCurrentUser(),
 
async: false,
 
completefunc: function (xData, Status) {
 
if ($(xData.responseXML).find(“Group[Name='Admingroup']“).length == 1) {
 
alert(“login inside of the Group user”);
 
}
 
else {
 
alert(“login outside of the Group user”);
 
}
 
}
 
}); /*close().SPServices({ */
 
}); /* close (document).ready(function() { */
 
</script>


















http://www.splessons.com/2014/08/check-if-current-user-is-in-a-specified-group-using-spservices/

No comments:

Post a Comment