I don’t want to display the user’s trust level, I did a custom leveling system that’s partly based on action made on both wordpress AND discourse.
Here’s the best workaround I’ve found so far:
// I fetch my JS object containing all my members with user levels, calculated server side.
$.get('https://www.latranchee.com/php/users/gamification.php', function( data ) {
users = JSON.parse(data);
});
// The function that will add users level next to their name
function add_levels(){
$('.topic-avatar img.avatar:not(.lvl)').each(function(){
var username = $(this).attr("title");
if(window.users[username]){
$(this).after("<span class='user_level_img'>"+window.users[username]+"</span>")
}
$(this).addClass("lvl");
});
}
// A timer that triggers the check Avatar function
window.setInterval(function(){
checkForAvatar();
}, 1000);
// A function that check if there's an image on the page without it's level being displayed.
function checkForAvatar(){
if ( $('.topic-avatar img.avatar:not(.lvl)').length ){
add_levels();
}
}
Far from optimal, but I guess it will have to do.