Drew_C
3 years agoBoss
Simple redirect to "my profile" page
Here's how you can create a simple redirect to land your users on their profile page via an easy to share URL.
- Create an endpoint called myprofileredirect with the following content:
<#if user.anonymous >
${http.response.setRedirectUrl(webUi.getUserLoginPageUrl("/plugins/custom/YourID/YourID/myprofileredirect"))}
<#else>
${http.response.setRedirectUrl("${user.webUi.url}")}
</#if>
(If you don't know the ID to use in the anonymous redirect, just save it and you'll see a link to "open the endpoint" where you can get the URL path). - Ask support to create two new vanity URLs, both pointing to the endpoint.
/myprofile
/me
Seriously, it's that easy (once published, of course).
The user.webUi.url FreeMarker object returns the user's profile ID and if a user isn't logged in, they'll be taken to the login page first, by way of webUi.getUserLoginPageUrl.
Enjoy!