Populate Current Loggedin User in People Picker

In one of my project we need populate current logged in user in People Picker by default. I have implemented below code to do it.

Add 1.7.2.jquery.min.js and jquery.SPServices-2014.02.min.js file in the master page or page level.

 
$(document).ready(function() { 
 ExecuteOrDelayUntilScriptLoaded(loadCurrentUser, "sp.js"); 
});

function loadCurrentUser() { 
 var userName = $().SPServices.SPGetCurrentUser({ fieldName: "UserName", debug: false});
 $('h3:contains("PeoplePickerFieldName")').closest('tr').find('div[title="People Picker"]').html(userName);
 $('img[title="Check Names"]').trigger('click'); 
} 

** Replace “PeoplePickerFieldName” with your people picker field name.

** Replace “userName” with your desired user’s user name to add other user in peoplepicker.

Let me know if you face any challenges.

Happy Coding.. 🙂

Regards, Jay Doshi