What is SPService? :
SPServices is a jQuery library which abstracts SharePoint's Web Services and makes them easier to use. It also includes functions which use the various Web Service operations to provide more useful (and cool) capabilities. It works entirely client side and requires no server install. We can say SPService is independent of SharePoint version. Write once execute any SharePoint environment. It will reduce the lot burden on the server by running the business logic on the client browser rather than in SharePoint Server.
Step1 :
Create one group and add one or more users into a group.
Step2 :
We can use below mention code in where ever to restrict the current user like application form, web-part or Content editor Webpart.
[javascript]
<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>
[/javascript]
Step3 :
We can see out put like below
If the user belongs to a group.