Login redirect to failed URL for 404 template
I don’t know if I’m the only one with this issue/request, but couldn’t find anything exactly like this elsewhere…
There are several pages on one of my sites which are private to logged in users, and if a non-logged-in visitor tries one of those URLs, WP disavows all knowledge of the page (404 error). What I would like to do is provide a login link on the 404 page (through template) which will redirect them to the URL they tried before.
1. Visitor clicks a link in email to a private page (no browser open/logged into site)
2. Visitor gets 404 error
3. Visitor clicks login link on 404 page, which logs them in, then retries the URL they clicked from their email.
4. Either they get another 404 (the link really was bad) or they get the private page, now that they’re logged in.
The best instructions I’ve seen so far suggest using get_permalink as the argument to the login link. Unfortunately, this works everywhere except the 404 page, which seems to consider the link false, and redirects me to the dashboard on login (like there was no argument).
I understand that although the address bar of the browser is displaying the URL that didn’t work, I’m not actually “at” that URL, but I want a simple way to get that URL and try it again. (I think there’s probably a way I can write a function to save that URL as a variable and then pass it back into the login link as an argument, but it really seems like this should be simpler than that.)
echo get_permalink()as the redirect argument doesn’t work either…
Thanks for any help!
- The topic ‘Login redirect to failed URL for 404 template’ is closed to new replies.