Want to redirect the just logged-in user back to the same page from where they filled in the login form? If you are using fluent forms, it is easily doable. Simply follow this tutorial.

First, let’s talk about the situation where we need to apply this, using the following question from a fluent forms user:

The question reads: “… I have elearning sites where I need to place some Login Forms in the content pages (so that only the registered users can access the content). I have already placed user registration forms on those pages that redirect and auto-log the users to the same pages after registration. However, when the registered user visits the same page NEXT TIME, he has to fill in the login form to access the content. So, now the question is, how to set up and WHERE TO SET UP the redirect url in the login forms so that when the user logs in, he lands on the same page and can view the content that I have wrapped in a conditional block that is “shown only to logged in users”.

“In the case of User Registration Forms, it was quite easy to create the “SAME PAGE REDIRECTING FORMS” just by placing this smartcode “{embed_post.permalink}” in the confirmation setting. But how to do this in the case of login forms?”

Alright, now let’s come back to the solution. If you have set up the user registration forms already using the fluent forms wordpress plugin, then this should be easier. So, to achieve our desired result, I assume that you have already created a login form. If you have not yet created that, you can go through this article for setting up a fluent form’s login form.

Now, to redirect the logged in user back to the same page from where they filled in the login form, you just need to change a few things from the script that you can find in the article mentioned. Simply change the script’s “$redirectUrl = home_url();” to “$redirectUrl = wp_get_referer();” and that will enable you to get your desired result..

Leave a Reply