I will do something like this :
- get username with the current session
- get the rest now you have the username with the API
$(document).ready(function() {
$.ajax({
type: 'GET',
cache: false,
url: 'https://discoruse.forum.com/session/current.json',
dataType: 'json',
xhrFields: {
'withCredentials': true
},
success: function(result){
// you get the username
result = result.current_user;
var user_name = result.username;
var user_id = result.id;
var user_avatar = result.avatar_template;
$.ajax({
type: 'GET',
cache: false,
url: 'https://forum.com/users/' + user_name + '/activity.json',
dataType: 'json',
xhrFields: {
'withCredentials': true
},
success: function(result){
// you get the email and date of registration
result = result.user;
var user_email = result.email;
var user_registation = result.created_at
},
error: function(result){
console.log('Error: '+result);
}
});
},
error: function(result){
console.log('Error: '+result);
}
});
});
You can insert this code into the body from the admin panel → cutomization