Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var SPGetSPcurrentUser = function(callback) {
var spuserid = "Error";
var context = new SP.ClientContext.get_current();
// Using this here would make it global, as the function is not called with 'new'
// and this would then point to the global object, window
//this.website = context.get_web();
var website = context.get_web();
var currentUser = website.get_currentUser();
context.load(currentUser);
context.executeQueryAsync(
function(sender, args) {
callback(currentUser.get_loginName());
}, function(sender, args) {
this.spuserid = 'request failed ' + args.get_message() + '\n' + args.get_stackTrace();
});
};
var thisuser = SPGetSPcurrentUser(function(thisuser) {
alert(thisuser);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.