I'm trying to use a link to pass a redirect parameter to my login form, so that it can redirect users back to the page they came from. Here's the code I'm using.
This successfully generated the URL hidden link when it's on /about/, which should be correct However, filling out the login form and hitting submit doesn't redirect to that page, it reloads the current page.
If I change the URL generated from /log-in (where my login form is) to /wp-login.php (so, hidden link) the redirect works - when you log in at that URL, you get redirected to the About page. However, I don't want to use the standard WordPress Login, as I've already set up and styled the login form generated by Views.
So, is there anyway to pass a redirect URL like this to a wpv-login-form Login Form?
You have registered the shortcode but don't appear to be using it.
I haven't tried this but I expect you should be able to modify your shortcode so that the URL is simply the page you want to redirect to (the full URL), and then use the shortcode for the redirect_url parameter of the wpv-login-form shortcode, like so:
That's not quite right. I want the shortcode to be on a different page than the log in form, say /about. So, I want the user, after clicking the link the shortcode creates, to be taken to the login form, and then, when they fill out the form, I want them to be redirected back to /about, or whatever page the link was on. Why I want this is to use it on user-created posts with varying URLS, so that people who aren't logged in can log in and then be sent back to the page they were on to see protected content there. For that reason, just putting the shortcode in the login form won't work, because that would just get the login page URL and reload that page.
Sorry, I didn't look closely enough at your shortcode to see what it does.
If you use that to link to your custom login page and have added a URL parameter "redirect_to" then you can access that URL parameter on your login page with the wpv-search-term shortcode (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-search-term), where the param attribute would be 'redirect_to'.
So try using wpv-search-term to generate the redirect_url attribute, like so:
I haven't tested this but I think it should unless you run into a problem with the shortcode format (using {!{ }!} instead of square brackets because you are adding this to a page builder module. If it doesn't work initially try changing the square brackets around wpv-search-term to the same brace format, and if that doesn't work try changing all to square brackets.
That worked perfectly! Thank you, that was something I'd been trying to get working for weeks.
It's also something that's been asked without resolution several times on these forums (how to have the login form redirect to the previous page). This doesn't work in every situation, just when people follow the link generated by the shortcode, but I still think it could be helpful.