how to get user details from your current user in SharePoint via jquery and webservices

This time we are going to look at SPServices, a great codeplex project, so freely available. The SPServices can be described as a jQuery library which abstracts SharePoint’s Web Services and makes them easier to use.
To demonstrate that, let us look at the SPCurrentUser function. This SPGetCurrentUser function does an AJAX call to grab /_layouts/userdisp.aspx?Force=True and “scrapes” the values from the page based on the internal field name (aka StaticName).

Code
So, some examples here:
To get the user ID:

document.write($().SPServices.SPGetCurrentUser({fieldName: "Name",debug: false}));

To get the telephone nr:

document.write($().SPServices.SPGetCurrentUser({fieldName: "WorkPhone",debug: false}));

In just 1 line you can get your user’s telephone number, name or any other field that is filled in on your dispform!
Amazing stuff..

About: Marijn

Marijn Somers (MVP) has over 14 years experience in the SharePoint world, starting out with SP2007. Over the years the focus has grown to Office 365, with a focus on collaboration and document management. He is a business consultant at Balestra and Principal Content Provider for "Mijn 365 Coach" that offers dutch employee video training. His main work tracks are around user adoption, training and coaching and governance. He is also not afraid to dig deeper in the technicalities with PowerShell, adaptive cards or custom formatting in lists and libraries. You can listen to him on the biweekly "Office 365 Distilled" podcast.