Can users make their User ID visible on their profile?

Is there a way for users to see their own User ID when someone views their profile?

Right now, IDs are only visible to admins through the dashboard, but I’d like users to be able to display their ID publicly.

Is this something that can be enabled through admin settings, a component, or a plugin?
Let me know! Please

It should be doable in a theme component. The user ID is available without an additional request, so you’d only need some JavaScript to show it in a plugin outlet on the profile page.

3 Likes

What’s the use case? Why is knowing a random integer important?

4 Likes

@pfaffman Thanks for the reply. Well, because a UID is immutable (never changes) it can act like a permanent fingerprint for someone’s account. Usernames can change so for support tickets it instantly can find their account, transactions, auth sessions etc… UID cannot be faked and are unique forever.
I would like the UID to increment by 1 with every new users

@Moin Thanks for the reply it was helpful. Yesd I can view the response in Network → XHR → Response. Perfect. But I am unaware as to how to show the UID on the users account profile. I want to display it here: https://mydomain.com/u//preferences/account
But within the create components there is only these options: , Before Header, After Header and Footer

This is ultimately what I would like.

I have got the UID to display with some JS but its only showing on the header of the main page

/my/preferences/account is not public; other users cannot see that, but based on your use case, it might be enough for the user themselves to see their ID.

You need to find a plugin outlet that is close to where you want to show the information. I usually use the button in the developer toolbar to make them visible on a forum. Seeing them within the forum makes it easier for me to find the best outlet. You can find more information on how to show something in an outlet in the Theme Developer Tutorial: 1. Introduction

Okay so if I want everyone to see it (public) I would place it within: mydomain.com/u/<user>summary
So by use of enableDevTools() within the browser console I think user-profile-secondary will be a good place.
I will try now.

Im stuck. How would I get the id of the user I am viewing? Because api.getCurrentUser does the logged in user.

I just put the User ID on plugin outlet: header-contents__after

1 Like

Custom Components -- add button or text at any plugin outlet is an example of how to stick some text anywhere that there’s a plugin outlet. I think you’ll need to create your own theme component to get access to the user_id.

I think you’d do something like this when you call your component:

        <YourIdComponent
          @user={{@user}}
        />
1 Like

But how do I get the user.id of someone else using code.

Using @pfaffman 's post above, you can then have a component that uses {{@user.id}}. See Theme Developer Tutorial: 5. Building and using components, but I think you can do it in Edit CSS/HTML > JS in the Discourse TC UI, using api.renderInOutlet().