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); } } </script>
Sharepoint Developer
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.