0

I have a site that I must redirect a logged in user to a page with a # in the url. Anytime this happens the only way to grab anything after the # is using JavaScript. I know I can grab what I want with something like this:

<script type="text/javascript">document.getElementById("redirect_to").setAttribute('value',"/docs/Default.htm"+window.location.hash);
</script>

But I can figure out how to have WordPress redirect to that /docs/Default.htm#444 page when someone comes into the site with that as the referral.

So... someone is on a site, clicks a link to my WordPress site example.com/docs/Default.htm#444 and I need the login page to appear if they're not logged in and have redirect_to be set to /docs/Default.htm#444

Best way to do this, or is it impossible? I can use a plugin, change the default wp-login or create an all new login page. I've not found a plugin that'll do this, and I've been unable to figure out how modify wp-login nor have I get a custom login page to work. wp_login_form seems to set the redirect_to no matter what and I don't see how to override that with a variable from that JavaScript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.