As SharePoint Online allows only JavaScript based code to do any updates, below example will show the way to update SharePoint Online user profile properties from site using SharePoint JavaScript object modal,
function startUpdate(){
SP.SOD.executeFunc("sp.js", "SP.ClientContext", function(){
SP.SOD.registerSod("sp.userprofiles.js", SP.Utilities.Utility.getLayoutsPageUrl("sp.userprofiles.js"));
SP.SOD.executeFunc("sp.userprofiles.js", "SP.UserProfiles.PeopleManager", updateUserProfile);
});
}
var userProfileProperties;
function updateUserProfile(){
//Get Current Context
var clientContext = SP.ClientContext.get_current();
//Get Instance of People Manager Class
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
//Get properties of the current user
userProfileProperties = peopleManager.getMyProperties();
//Get only the accountname instead of all the properties.
clientContext.load(userProfileProperties, "AccountName");
//Execute the Query.
clientContext.executeQueryAsync(function(){
var currentUserAccountName = userProfileProperties.get_accountName();
//Couple of properties for example
peopleManager.setSingleValueProfileProperty(currentUserAccountName, "CellPhone", mval);
peopleManager.setSingleValueProfileProperty(currentUserAccountName, "SPS-HireDate", hval);
//Birthday date format must be month name & date (October 19)
peopleManager.setSingleValueProfileProperty(currentUserAccountName, "SPS-Birthday", bval);
clientContext.executeQueryAsync(function(){
alert("Updated!");
},
function(sender,args){
alert(args.get_message());
});
}, function(sender,args){
alert(args.get_message());
});
}