I need to add a “Back” link that goes back 1 page (history.go(-1)
) UNLESS the previous page is a specific URL. In that case, I want the link to go back 3 pages (history.go(-3)
).
I thought this would be simple by using either document.referrer
in JS or $_SERVER['HTTP_REFERER']
in PHP, but in both methods, the referring url is always blank, so obviously that won’t work.
The referring url that I want to skip would contain the following parameter at the end: ?um_action=edit
So for example, a user might take this path:
- mysite.com/directory
- mysite.com/member/profile
- mysite.com/member/profile/?um_action=edit
- mysite.com/member/profile
If you are on step 1, 2 or 3, the back link would take you back to the previous page. But if you are on step 4, I want the back link to jump back to step 1.
How can I achieve this? This is a wordpress site, and there is an action I can hook into that runs on step 3 above when the profile is saved. Could I use this somehow?
Thank you!
3