Modify Welcome Menu username Jquery

Needing to deal with grabbing the username displayed in the top-right SharePoint welcome menu and reverse the lastname, firstname format it was in, I came up with the following Jquery script.

It takes the welcome menu root takes in the style of “Smith, Joe” and turns it into “Joe Smith”, with having to mess with User Profile Synching or feature stapling. You could adapt it for any other need in a jiffy. The important thing to note is that grabbing the client side ID of the welcome menu is done with a wildcard expression, since the clientside ID is prone to changing – for example it could be “zz16_Menu_tt” one time and “zz12_Menu_tt” the next:

<script type="text/javascript">
ExecuteOrDelayUntilScriptLoaded(ReOrderUsername, "sp.js");
        function ReOrderUsername() {
		var userName = $('[id$=_Menu_t]').children("a").children("span").text();
		if(userName.indexOf(", ")!=-1) {	
		      var fnstart = userName.indexOf(", ", 0);
		      var fnend = userName.indexOf("<",fnstart);
		      var lastName = userName.substring(fnstart, fnend);
		      var firstName = userName.split(", ").pop();        
	              $('[id$=_Menu_t]').children("a").children("span").text(firstName + ' ' + lastName);

One response to “Modify Welcome Menu username Jquery”

  1. Good Script… will try to use it one of my project and see what does it looks like…. If found appealing than can recommend it to use in other projects for sharepoint development as well.

Leave a Reply

I've been low-key stressed about how to view the many email inboxes I have in Outlook in one view without having to scroll and hunt for new messages.

The 'macro' method in this video works great.

View Multiple Inboxes at Once in Outlook 365 via @YouTube

We help Department of Defense clients realize benefits such as faster decision making, total traceability, and automated updates by identifying targeted goals and putting an emphasis on a culture of adoption through buy-in by individual team members.

How to: Create a report quickly from a #SharePoint list or library in the #PowerBI service

Leverage Microsoft Project for the web with the Project Accelerator via @YouTube

Load More...