Public user profiles with direct links

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?

Use the set slug action and set the slug as username.

It’ll replace the ID with slug value in URL

2 Likes

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.

Hi,

Your didactics are correct. However, you made sure to define Get path from page URL as “Path”?

image

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.

image

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?

That thread is way outdated and the method explained there is no longer required.

Just set the thing’s slug, and use that in the URL path instead (for internal links, Bubble will do this for you).

1 Like

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.)

You can create a backend workflow and trigger it by going to your data and choosing ‘bulk’.

And then create workflows to create the slug automatically when a user signs up to avoid having to do the backend.

That makes sense on backend workflows, so sounds like I have some learning to do since that’s new for me.

I did manually add some slugs to test the rest of what you mentioned and I’m not getting the right results yet. Here’s what I set up in my workflow:

And on the page itself:
Screen Shot 2023-06-21 at 10.29.01 PM

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.

On the actual page itself, set the data type to User.

On Page Load, Get data from URL, type User.

Hopefully that will get you there!

Yeah, I have the page setup for User:

Screen Shot 2023-06-22 at 11.10.44 AM

Other ideas on what might be wrong?

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.

1 Like

@nico2023 heres a video on how to do it

Make sure to check your privacy rules too.

1 Like

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:

But the data isn’t populating in the preview from the correct URL.

1 Like

You’re using parent group in the data. Make sure none of your parent groups are missing “current page user” as data type

Also check privacy rules.

Shouldn’t I be able to set the group everything else is in as “current page user” and then items within that group to “parent group’s user”?

Yes but it should be working.

From screenshot you have a main group which is a row. I suspect you have another row group & a column group there.

Ensure the main group is “current page user” and EVERY nested group has the data source parent group.

If that’s all good then it’s privacy rules.

If you want to to settings, general, and turn it from a private app to anyone can edit and DM me the link I’ll screen record where your issue is.

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.

1 Like

Yeah, I think I’m going to have to go about it that way at this point. Just got to muster up the energy to do it haha

1 Like