Get Current user details using SPServices in SharePoint

This SharePoint SPServices tutorial explains, how to retrieve current user details using SPServices in SharePoint Online or in SharePoint on-premise. We will retrieve username, email, first name, etc using SPServices in SharePoint 2013/2016/Online.

Get Current user details using SPServices in SharePoint

You will be able to retrieve current user details like UserName, Email, FirstName, LastName ID, etc using SPSercices in SharePoint 2013 Online. In the end, find all the properties. You can retrieve single column values as well as you can also able to retrieve multiple column values. See 2nd example of this.

Below is the full code to retrieve current user details using SPServices in SharePoint Online or SharePoint 2013/2016.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
alert($().SPServices.SPGetCurrentSite());
alert($().SPServices.SPGetCurrentUser());
alert($().SPServices.SPGetCurrentUser(
{
fieldName:"ID",
debug:false
}
));
alert($().SPServices.SPGetCurrentUser(
{
fieldName:"UserName",
debug:false
}
));
alert($().SPServices.SPGetCurrentUser(
{
fieldName:"FirstName",
debug:false
}
));
});
</script>

Get multiple column values:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.min.js"></script>
<script type="text/javascript" language="javascript">
$(document).ready(function() {
var userdetails= $().SPServices.SPGetCurrentUser(
{
fieldNames:[“ID","EMail","UserName","FirstName","LastName"],
debug:false
}
);
alert(userdetails.ID);
alert(userdetails.EMail);
alert(userdetails.UserName);
alert(userdetails.FirstName);
alert(userdetails.LastName);
});
</script>

Below are the user properties which you can retrieve:

get current user spservices

You may like following SPServices SharePoint 2013/2010 tutorials:

Hope this will be helpful to retrieve current user details like username, email id, first name, last name, etc using SPServices in SharePoint 2013/2016 or SharePoint Online.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>