bbPress

Simple, Fast, Elegant

bbPress support forums » Requests and Feedback

here's a trick to redirect user back to topic after login

(5 posts)
  • Started 5 months ago by _ck_
  • Latest reply from hellweaver666
  1. I had not seen this posted before and I just (finally) figured it out so I thought I'd share.

    If you'd like to give the user a friendly redirect back to the topic (or forum) they were at just before they logged in (instead of the front page) simply open the login-form.php template in your theme and add this BEFORE the final </form>

    <input type="hidden" name="re" value="<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER["REQUEST_URI"].'?'.$_SERVER["QUERY_STRING"]; ?>" />
    <input type="hidden" name="_wp_http_referer" value="<?php echo  bb_get_option( 'uri' ) ?>" />

    Should work on anything except maybe IIS.

    Posted 5 months ago #
  2. Very nice... that was on my todo list to figure out.

    You rule. As usual.

    Posted 5 months ago #
  3. I should note that mdawaffe has pointed out to me that apparently bbPress would do this previously if the user has referer's enabled in their browser. But since most "personal firewalls" block referers by default, you can't count on that behavior and this change will make it always work instead.

    0.8.4 will supposedly have this new ability by default...

    Posted 5 months ago #
  4. For my site, I'm using the bbpress login as the site-wide login... so when I put a login link on the wordpress side of the site the user would be redirected to the forum every time after login... kinda annoying.

    With this new knowledge I should be able to fix it so they are redirected back, even to a non-bbpress page.

    Posted 5 months ago #
  5. Works a charm - thanks _ck_

    Posted 2 weeks ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.