I understand how to build a user profile, but what I’m stuck on is trying to have a clean URL based on username rather than ID (e.g., website.com/profile/username). I’d like people to be able to go directly to a user profile (their own or someone else’s) from a simple URL name, but I’m specifically struggling with using a URL component to set the data for the page.
I essentially want to do what’s discussed in this older thread, but I’ve followed all those instructions and haven’t been able to pull in the correct users.
In the steps from @romanmg , I don’t totally understand how Bubble would recognize a username specifically in my URL path text so maybe seeing what that looks like would help?
What you’ll need to do is to set a slug on each user, based on that user’s username. Then, create a workflow, ‘On Page Load’, ‘Go to page’ [Profile], or [whatever else you are calling this page], Data to send: get path from Page URL, type ‘Path’, Type ‘User’. Then for your group, just set the data source to ‘Current page’s user’.
Now, when the page loads, it should pull the user from the slug in the URL, and the group will then reference that user’s info.
Your didactics are correct. However, you made sure to define Get path from page URL as “Path”?
Make sure to also connect all the groups with a data source to the element from which you want to fetch the profile/username data.
I have the exact same logic in my application, and it seems to be working correctly. If by any chance it doesn’t work, could you provide the link to your editor so that we can take a look?
I have a lot of users; will I need to do a bulk export/import to set all the user slugs retroactively or is there another way? (I have a couple of data storage fixes I need to do on all users and I’ve been dreading tackling this.)
When I preview the page, I obviously have to manually add in a slug (replacing the sample Lorem ipsum) then reload, but the groups still aren’t displaying any user info.
use slug to access a specific object at page level content type, this why it exists.
If you want just to export a list of slugs from a user list, create an input text box (it will be important for you to copy&paste out of it), set the default value as the result of:
query of all users → for each slug → join text → separated by “[enter]”.
The result will be the text box filled with all the slugs that you can easily copy&and paste out of bubble.
The slug is “current page user” data you can’t have one without the other. As long as there’s a slug it should populate from that data using current page user.
You don’t have to “get data from URL” at all. That’s what current page content is already doing.
Let me clarify the part I’m stuck on: I have the URL functioning as expected, but elements on the page that rely on user data set by that aren’t populating. Setup:
I’ve checked privacy rules and things look good there.
On columns and rows: I only had 1 Group set up as a column, within which there’s a combination of row and column containers.
I’m realizing there might be a complicating factor at play: some of the groups on this page rely on a data type other than User (I basically set them up to pull in another data type created by the relevant User). But I tried deleting these outlier elements, and the remaining nested groups are indeed set up to have the parent group data source, which I’d then expect to work. So I’m still not finding my culprit.
Could you try simplifying just for the purposes of troubleshooting, and go ‘clean-slate’ with JUST one group, type user, inside page type user, and seeing if the fields are loading based on slug? From there you can grow outwards but it would certainly help to eliminate some of the outlying groups to pinpoint what is going on with the data flow.