Sign in redirect

Okay, I find it rather hard to believe that I’m the first to ask this question but I did search it for the last few hours online and have not come up with a viable answer so I must word things badly or something. What I am looking to do is… I have a sign in link at the bottom of my forum topics that anyone not logged in sees. I want to have them redirected back to the same page that called sign in once they have finished signing in.

In other words you are currently reading a topic post called “I can win.” but you’ve forgotten to log in and so you can not post a reply. But there is a link there to take you to the sign in page. Upon signing in I wish to redirect the user back to the page they clicked the sign in link from, the topic post of “I can win.”. So far, I’ve been fighting this for a few hours and I’m not winning. LOL! The sign in link is inside of a <?php call if that makes any difference. It looks like this…

It’s inside of the form-reply.php and yeah, I’ve already edited it a bit but as you can plainly see I have a link there to Sign in. I need to know how to make the sign in page bring them back to where they clicked on this link from, once they’ve signed in.

I hope that I’ve made my problem clear enough and I hope there’s an easy answer out there somewhere. Any help would be appreciated!

And it works… When you’re on the login screen UP UNTIL YOU PRESS SUBMIT the redirect shows correctly in the URL. WHEN YOU PRESS SUBMIT to actually login the system then redirects your redirect to PROFILE.PHP and I’m so far unable to locate which file this secondary redirect is bothering me from. I’ve butchered wp-login.php and the system doesn’t even seem to care. I think I could erase the file entirely and the system wouldn’t care.

What file is BuddyPress using to control User Login’s, if it’s not using WP-LOGIN.PHP? I’ve been unable to locate that too. I figure my secondary redirect headache MUST be in that file somewhere.