Individual URL for users

Hi so i am trying to make a individual profile page url for users

I found a similar question back in 2017 but i cant figure out a part to make it work

@romanmg said this

You can store a user’s unique path string in a text field under the User type and then append that as a path to the profile page url. For example “myapp.com/profile/john-henry ” or “myapp.com/profile/naturalfoodstore ”. What you’d be storing is just “john-henry” or “naturalfoodstore”.

So anytime you navigate to the profile page and want to specify a user, you’d use an external link action (or link element) to go to “http://myapp.com/profile/ [current user’s path]” … or [current cell’s user’s path] if triggered from a repeating group.

Then, on the profile page, since you’re using the path to identify the user, one way to make the page dynamic is to put everything in the page inside a group. Set the group’s type to User and the source to “Search for Users: first item, constraint: path = get path from page URL”. Then everything within would just be “Parent groups [field]”

“Get data from page URL” has 2 types available - parameter and path. Choose Path.

Search the forum for more on this because this is a great way to create “pretty” custom URLs.

But for this part:

Set the group’s type to User and the source to “Search for Users: first item, constraint: path = get path from page URL”. Then everything within would just be “Parent groups [field]

I cant seem to do the constraint for the path???

Anyone knows what is going on??? Please i really need help

I tried doing constraint in the “Search for Users” or “filtered” but both dont seem to have the option to start the constraint with Path ??? only the field types i listed for User… Anyways please help!!!1

If I understand correctly, I think what you’ll want to do instead of a Search for Users, filters, etc, is simply setting the User’s individual / unique name as their Slug, and simply setting the page type to ‘User’. Now the URL w/ the user’s Slug at the end of it will automatically load.

okay, i have considered that but what i am trying to do is by referencing the username from the path in the url, identify the user with that username and display their avatar using a dynamic data

Does that make sense?

Right now im trying to get it to search for the correct user based off the path in the URL. Any idea how to?

It does make sense, although the problem with that is you’ll have to setup proper restrictions in place to make sure the username is unique, otherwise this approach won’t work. The Slug workflow takes care of ensuring unique names, and appends with numbers (for example if there’s already a john-smith, it will create john-smith1). Additionally using Slugs you don’t need to setup any sort of ‘do a search for’ parameters - simply having the slug in the URL is all it needs to know what it needs to do.

erm okay but 1 question - i still need to input dynamic data into the image box to show the user’s avatar right? so what goes into the dynamic data?

Do you have an example of perhaps the expression?

You should just need ‘Current User’s Avatar’ - the page’s user’s Slug being in the URL and that avatar being on the User’s datatype should be all you need.

Okay sorry if this sounds dumb maybe im tripping

but doesn’t current user mean the user who is currently logged into the account? If i need the users to be able to see each other’s profile shouldn’t i need some sort of expression to reference to the slug and display that user’s profile instead?

You are correct, ‘Current User’ means ‘currently logged in user’ - of you need users to see other user’s profile, than instead of Current User, you’d use ‘Current page’s user’.


there is no option for current page’s user though

Do you have a Type of Content set on your page?
image

Okay that’s great found it, thanks a lot

One last question: when navigating to the profile page, i should send data of the Slug as a path and the avatar display would be current page’s user’s avatar correct?

Am i missing something here? what else am i supposed to add

image

You use Current User not Current User’s Slug

1 Like

Johnny is correct - another benefit of using a slug is Bubble knows to show it automatically.

1 Like