User ID equivalent in Kirby 3


we are currently porting our K2 website to K3.

On our site we have a “team” page which for each team member provides a link to our contact form with the username as parameter to contact the individual team member, e.g. /contact/john-doe

A main reason for the contact form is to not have the email addresses of users written on the website. So I don’t think it’s a good solution to pass their email in the URL (and I also don’t want to pass it via POST etc.).

So what unique identifier can I use in K3 to pass to the user to the contact form?

Is this what your looking for?

If it is not, You could use a hidden field in the user meta files. Then just give it the same value you have for each user in your K2 site.

There is also Html::email() that will scramble the email so you can safely use it on a webpage. You can just scramble the email with Str::encode if you dont need the full mail tag.

1 Like

The id is your best bet, I think, its just a unique random string. As long as you don’t have to identify your users in the long term by that string even if you have have to recreate your users, you should be fine with using it for the purposes of the contact form.

I was only looking at $users in the docs, completely forgetting about $user and $user->id() in particular. Thanks for pointing it out.

Though I think I will go for $user->username() with a username format of "$firstname-$lastname".