Introduction
This article introduces how to Check user group of sharePoint site in SharePoint 2010 by using spservices.
Procedure
Step 1: Create sharePoint site, create user group and add one user in group.ex: i have added laxman vyavahare in manegement group as in shown below:
Step 2: Create sharepoint list.
Step 3: Open your Lists NewForm.aspx or EditForm.aspx page by using Sharepoint Designer and pase fallowing code under <script> tag.
- <script type="text/javascript" src="../../Js/jquery-1.7.2.min.js"></script>
- <script type="text/javascript" src="../../Js/jquery.SPServices-2013.01.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='Management']").length == 1)
- {
- alert("Management group user Login");
- }
- else
- {
- alert("login outside of the Group user");
- }
- }
- });
- });
- </script>
Step 4: Save the NewForm.aspx or EditForm.aspx page , then go to your site and login with user name which you created under group.
Step 5: open your list view and Click on Add new item as in fig.
Here you can check group user login....
Note: You can download latest JQuery for SPServices from http://spservices.codeplex.com.