Skip to main content

Redirect on login?

This may be a dumb question and I may be missing something obvious.
My site requires users to login to see any content. Is it not possible to have users redirected to their initially linked page after logging in?
For example, let's say I email someone a link to a space. They click the link but they aren't currently logged into FC so they get redirected to the login page. Then they are just sent to the home page (feed). Is there not a way to redirect to their original target page/space after FC login?
Thanks!

Hello, we will review this matter, thank you.

Thomas Oates

Tawsif Ahmed RiyadΒ Thanks. Any idea on possible timeline?

Thomas Oates, i will address the matter to my team lead, we will analyze and review the matter, there are some things that need to be checked, measured. I will give you an update in the upcoming days.

Thomas Oates

Tawsif Ahmed RiyadΒ Thanks. I did some testing and looking at code. Maybe this info will help.
Manually adding redirect_to to the login page works for redirecting the user after logging in. For example, I have a WordPress page at /volunteer. If I manually add the redirect_to value to the URL, I get redirected after logging in. Example:

https://fc.domainname.com/?fcom_action=auth&redirect_to=/volunteer

So that part works. The problem is the redirect_to isn't getting added to the authentication URL. It looks like the following code (note: screenshot not from latest release) in PortalHandler.php was designed to add the redirect_to value. The problem is the originally requested URL path isn't available at that point in the code (based on my testing).

1.00

Thomas Oates, if you have updated the plugin with the latest version, you can check out redirect on login/signup.

Thomas Oates

Tawsif Ahmed RiyadΒ Thanks! I'll update our test environment and check it out. Appreciate it!

Thomas Oates

Tawsif Ahmed RiyadΒ The redirect works fine if redirecting to a space or presumably other parts of FluentCommunity (I've only tested redirecting to a space so far) but it does not work for regular WordPress pages. The redirect_url strips off the slug for regular WordPress pages and just redirects to the site home page. Can it be modified to support redirecting to regular WordPress pages also?

Thomas Oates, sharing a screen recording will be helpful. But the redirection is based on the privacy of the portal community (only if logged-in users), only for the community routes.

1.00

Thomas Oates

Tawsif Ahmed RiyadΒ I'm running FC at the root of my site (no /portal). I have a regular WordPress page located at https://site.topleveldomain.dev/calendar. If an existing user goes to https://site.topleveldomain.dev/calendar while they are not currently logged in, the user is sent to the FC login page as expected. The URL at that point before the user logs in is https://site.topleveldomain.dev/?fcom_action=auth&redirect_to=https://site.topleveldomain.dev. Since the user was attempting to go to https://site.topleveldomain.dev/calendar, I'd think the redirect_to value should be https://site.topleveldomain.dev/calendar instead of just https://site.topleveldomain.dev. The full original requested link is getting cut off and only redirecting to the main site URL.

As a test, while on the login page, if I add /calendar to the redirect_to parameter and login, it correctly sends me to the /calendar page.

So, the issue is that the redirect_to value is not keeping the originally requested URL (/calendar in this example).

Thomas Oates

Tawsif Ahmed RiyadΒ I replaced the renderFullApp function. Now it removes the entire redirect_to value except for the /. You can see it happening by going to https://prideonline.alphadeltapi.dev/calendar. The login page URL now changes to https://prideonline.alphadeltapi.dev/?fcom_action=auth&redirectto=/.

If it helps, the $url value after the $url = home_url line is https://prideonline.alphadeltapi.dev so the /calendar part has already been stripped at that point.

Thomas Oates,Β we are using only the relative path now (updated the work in dev), as this is how it should be. Check with a space post or user profile route or any community routes, it will work. Still, I will check the outside portal routes in my free time; currently, we are on vacation.

Thomas Oates

Tawsif Ahmed RiyadΒ Thanks for all the help. I apologize but I found an issue with my theme that was causing the redirect to not work for regular WordPress pages. It works perfectly fine now after fixing my theme. Again, apologies for the extra work. Thanks for all the help and for making a great product.

Thomas Oates, that's great. One more thing, redirection works on signup/registration too.

arjun arjun

This is indeed a feature that is very important from the UX perspective.