Is there any web part that display info about current logged user, like name, position, phone?

I tried to export Profile details webpart from MySite (site for user profiles) and imported to homepage of main site, but it doesn't work (show nothing).

4 Answers 4


You can put below code to script editor webpart to show current logged in user's details.

<script type="text/javascript">
var currentUser;
function init(){
    this.clientContext = new SP.ClientContext.get_current();
    this.oWeb = clientContext.get_web();
    currentUser = this.oWeb.get_currentUser();
    this.clientContext.executeQueryAsync(Function.createDelegate(this,this.onQuerySucceeded), Function.createDelegate(this,this.onQueryFailed));

function onQuerySucceeded() {
    document.getElementById('userLoginName').innerHTML = currentUser.get_loginName(); 
    document.getElementById('userId').innerHTML = currentUser.get_id();
    document.getElementById('userTitle').innerHTML = currentUser.get_title();
    document.getElementById('userEmail').innerHTML = currentUser.get_email();

function onQueryFailed(sender, args) {
    alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
<div>Current Logged User:
    <span id="userLoginName"></span>
    <span id="userId"></span>
    <span id="userTitle"></span>
    <span id="userEmail"></span>

OR you can use below code which uses SPService

<script src="/Scripts/jquery-1.10.2.min.js" type="text/javascript"></script>  
<script src="/Scripts/jquery.SPServices-2014.02.min.js" type="text/javascript"></script>  
<script language="javascript" type="text/javascript" src="/Scripts/jquery.SPServices-0.7.2.min.js"></script>

<script language="javascript" type="text/javascript" src="/Scripts/sputility.min.js"></script>

<script type="text/javascript">  

$(document).ready(function() {  
    // get the title of current user  
    var UserName= $().SPServices.SPGetCurrentUser({  
    fieldName: "Title",  
   debug: false  
// get department of current user
var userDepartment = $().SPServices.SPGetCurrentUser({
   fieldName: "Department"
     // alert(userDepartment);

// get Phone of current user
var userPhone = $().SPServices.SPGetCurrentUser({
   fieldName: "WorkPhone"

//populate the field ‘Requestor’ with the current account  


$('textarea[title="Phone Number"]').val(userPhone); 
$('input[title="Phone Number"]').val(userPhone);



To check the internal names of fields, kindly check below URL.


Note :-

This script gets the few details of current user you can get the more details by using appropriate variables.

  • @Roman, Is that helps you?
    – Hardik
    Commented Jun 7, 2016 at 14:07
  • 1st part code works awesome , 1 req, i have a list with a status column so according to open/close i need to display text , how will i write that in the above code ? @Hardik
    – OM-ॐ
    Commented Mar 15, 2018 at 11:51

Use Rest to get current logged in user details as below

$(document).ready(function () {

    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/sp.userprofiles.peoplemanager/getmyproperties";

    url : requestUri,
    contentType : "application/json;odata=verbose",
    headers : { "accept" : "application/json;odata=verbose" },
    success : onsuccess,
    error : onerror

    function onsuccess(data){
    function onerror(errorMessage){

Using below code you will be able to find User Name, Login ID, User ID, Email ID of the current logged in user

$(document).ready(function () {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', LoadCurrentUser);

function LoadCurrentUser() {
    var context = SP.ClientContext.get_current();
    var siteColl = context.get_site();
    var web = siteColl.get_rootWeb();
    this._currentUser = web.get_currentUser(); 
    context.executeQueryAsync(Function.createDelegate(this, GetCurrentUserProperties), Function.createDelegate(this, LoadUserfailed));

function LoadUserfailed() {

function GetCurrentUserProperties()
    var loginName = this._currentUser.get_loginName();
    var email = this._currentUser.get_email();
    var userid = this._currentUser.get_id();
    var username = this._currentUser.get_title();

You could use InfoPath forms where you can use SharePoint web services to retrieve info from the logged in user.

Check this link for the SharePoint Web Services

Publish InfoPath form to SharePoint and then add to your page the custom InfoPath form control (custom web part) you have just published.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.