Forums

Join
bbPress Support ForumsPluginsRedirect to last page after signin

Info

Redirect to last page after signin

  1. I've integrated my WordPress (2.5) install with my bbPress (0.9) install... and have the signin for both routing through the bbPress bb-login.php.

    There are signin fields at the top of every page:
    * http://www.weddingbee.com (the WordPress blog)
    * http://boards.weddingbee.com (the bbPress forum, on a subdomain)

    When users signin to a page on the boards, they stay on whatever page they are on. However... when user signin through the blog... they get sent to boards.weddingbee.com (the bbPress install frontpage). This annoys some users, because they have to navigate back to whatever blog page they were on in order to comment.

    I looked at the bb-login code, and there seem to be references to keeping track of the referer and redirecting using redirect_to. Does anyone know how to use those, so that when my users sign into a page... they stay on that page, rather than being redirected to the boards frontpage?

  2. How about this:
    http://bbpress.org/forums/topic/heres-a-trick-to-redirect-user-back-to-topic-after-login#post-14268

    There was a hidden field with a name of "re" that you could use to redirect the user.

  3. Ah that looks really promising - I'll try it out! Thanks so much. :-)

  4. Ah it looks like that code is for bbPress... it has a reference to bb_get_option in it:

    <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' ) ?>" />

    If I stick it into a WordPress template for my header.php file, it crashes... any ideas how to make it work in WordPress?

  5. Sorry, I thought you said you were routing all the logins through bb-login.php - this *is* bbPress code. Where do you need to use the code? What are you trying to do again?

    You're sending all your users through bbPress for login, but when a blog user gets sent to the forum for login, they're not returned to the page they were on, but to the forum front page? Is that accurate?

  6. This does not go in any WordPress files at all. It goes in your bbPress login-form.php template file, right before the closing </form> tag. That way, after submitting the form, bbPress directs the user back where they came from (all those SERVER VARIABLES in the code snippet.) I thought this did exactly what you were looking for. Where did you try to insert the code?

  7. You can do a similar hack on the wordpress side too, except it's easier because wordpress doesn't need a referer , you just do it in the url.

    ie.

    wp-login.php?redirect_to=<?php echo $_SERVER['REQUEST_URI']; ?>

  8. I stuck the code into bbPress in login-form.php, but it didn't work.

    There's a form on the WordPress side of things, in my WordPress header... I thought maybe that needed to be changed as well? It posts into the bbpress auth...

  9. You must log in to post.