I'm new to stack exchange and I have a question:

On my site, a WP classified theme, I have it setup that when a user clicks on the "contact buyer" link and that user is not signed in, the login page loads. Once logged in, the page redirects to their dashboard.

I'd like the page to redirect to the page they were intending to access (contact buyer). I've seen http referrer and a few others snippets, but for some reason I can't get them to work with wp-admin sign in??

Also, I'm mindful of users initial sign in and how this maybe a problem.

Any help would greatly appreciated.


You did not mention any method or post any code, so I'm going to leave a blind answer here. I can update it if you add more information.

Generating the login link takes place by wp_login_url(). This function accepts an argument, which determines redirection after login. You can use it this way to redirect your visitors after login to wherever you wish:

wp_login_url('SOME URL HERE');

To make it dynamic, use it in conjunction with site_url():


This will redirect the user to example.com/contact-buyer/ after logging in.

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.