We have SP2013 on site. Access is controlled through our active directory and therefore SP always knows who is using the page. In the upper right of the suite bar we get our name but none of the other expanded user info is there -- at least that I can find.
We have a lot of features -- contact us pages, other forms, discussions -- where we want to know details about the user.
I had added some javascript to request the user information and add it as a data node to the body. I used jquery to run this when the document was ready. But unfortunately in some cases the timing doesn't work right and other code which needs that information tries to run before the info comes back.
Pretty much everything I do is client side javascript and I don't know much about aspx pages and how to work them. Is there a way to add this directly to the masterpage and have it happen on the server side so I can count on the user info being there from the get go?
Edit
Part of the problem was I had document ready in a couple of spots and couldn't count on the order of them going. Here is the code I'm currently using which seems to be a bit better. (Sorry for the readability, I only have the unminified version...) My concern now is that the $.holdReady(true) might try and execute before jquery is available.
(function() {
// tell jquery to not execute an $(document).ready()...
$.holdReady(true);
function e() {
var e = new SP.ClientContext.get_current(),
o = e.get_web();
c = o.get_currentUser(), e.load(c), e.executeQueryAsync(n, t)
}
function n() {
$.data(document.body, "currentUser", c);
// got the values back $(document).ready() can go!
$.holdReady(false);
}
function t(e, n) {
// well no results, but lets not break everything else
// let the rest of the $(document).ready() go
$.holdReady(false);
}
var c;
null != SP.ClientContext ? SP.SOD.executeOrDelayUntilScriptLoaded(e, "SP.js") : SP.SOD.executeFunc("sp.js", null, e)
})();