SharePoint SPServices Check User Group

To check Logged in user group using SPServices use below code.

<script language="javascript" type="text/javascript">

$(document).ready(function() {
    CheckUserGroup();
});

/* ----------- Check User Group Code Begin -------------*/
function CheckUserGroup(itemid) {
        $().SPServices({

            operation: "GetGroupCollectionFromUser",

            userLoginName: $().SPServices.SPGetCurrentUser(),

            async: false,

            completefunc: function(xData, Status) {

                if ($(xData.responseXML).find("Group[Name = 'Administrator']").length == 1) {

                    alert("Logged In User Group :: Administrator ");

                    /* ----------- Enable Disable Control Start -------------*/

                    //$("#divEmployee :input").prop("disabled", true);

                    //$("#btnSubmit").removeAttr('disabled');

                    /* ----------- Enable Disable Control End -------------*/

                } else {

                    alert("Logged In User is OutSide Of Adnministrator Group");
                }

            }

        });
    }
/* ----------- Check User Group Code End -------------*/
</script>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s