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="https://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="https://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.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>