Understanding how trust level works

I use the following code in order to get user’s trust level:

const trustLevel = helper.attrs.user_trust_level;
const trustLevelName = trustLevel ? Discourse.Site.currentProp('trustLevels').findBy('id', trustLevel).name : '';

But I noticed that if user has trust level zero it will not give me the name “new user” rather the empty string. Why helper.attrs.user_trust_level is not defined for new users?
Thank you :slight_smile:

1 Like

You could easily handle that case by modifying your first list to

const trustLevel = helper.attrs.user_trust_level || 0;

And your second line would be much faster like so