User profile page by id?

AI-generated summary

The discussion revolves around accessing a public user profile using their ID. John_Lehmann wants to link profiles on their main site to profiles on their Discourse site, but usernames are inconsistent due to a transition to SSO. They are looking for a route to access a user’s profile using their ID, similar to https://meta.discourse.org/u/{user-id}/summary.

John_Lehmann clarifies that they want any user to be able to view another user’s profile on Discourse by clicking a link on their main site. They also suggest a need for a PUT endpoint to update usernames, which would simplify the process.

simon responds that a POST request to /admin/users/sync_sso can be used to sync SSO user data, which can help achieve the desired outcome.

Is there a route to access a public user profile using their id?

I’m aware of: https://meta.discourse.org/u/{username}/summary
And I want: https://meta.discourse.org/u/{user-id}/summary

Purpose: I want profiles on my main site to link to profiles on my discourse site. The problem is initially I wasn’t using SSO so the usernames are not all consistent between my two sites, and are being update as the user logout/login. I attempted to “flush” out the old user ids only to realize there is no endpoint for me to update usernames (you can only update email and avatar).

Because usernames are changing, I stored id instead, but now I realize I cannot directly generate a URL to get to their profile with id. I would have to do additional web requests which I am trying to avoid. Otherwise, I think I have to hit the by-external endpoint once to get the username, but a redirect would be nice.

If you’re trying let users get their own profile, yo can use /my/summary/

https://meta.discourse.org/my/summary

Thanks but no, I want any user viewing a profile on my main site, to be able to click a link on that page to take them to the corresponding profile on the discourse page.

It would be great if there were a PUT endpoint for username. The use case is sites like mine which transitioned to SSO, to get all the usernames synced. Then my plan A would have just worked.

My fallback plan I think is going to be to add another column to store discourse_username also in my DB along with discourse_id. This way, I can directly to their profile with username. The downside is that this username can change. So I need to daily scan all users to re-sync.

You can make a POST request to /admin/users/sync_sso for this. If you are using the Discourse API gem, you can use the gem’s sync_sso method for this. If you are not using the gem, see Sync DiscourseConnect user data with the sync_sso route for details about setting up the request.