If you are using buddypress,I am sure In most of theĀ cases you are going to have a login form on all the pages(I know It depends on theme ,but most of them have it in this way)
When a user logs in from an arbitrary page,what happens,If the login is successfull,the user is redirected to site home page.Is it the behavior a user expects .Should It be considered a default behaviour.
Of course not,If I am logging from a page,I want to be on that page after login.
So ,here is a small tweak to make it happen.
Have a look at the code where the login form is put.
In case of default theme it is in bp-sn-parent/header.php
you will see something like this there
<form name="login-form" id="login-form" action="<?php echo site_url( 'wp-login.php' ) ?>" method="post">
<input type="text" name="log" id="user_login" value="<?php _e( 'Username', 'buddypress' ) ?>" onfocus="if (this.value == '<?php _e( 'Username', 'buddypress' ) ?>') {this.value = '';}" onblur="if (this.value == '') {this.value = '<?php _e( 'Username', 'buddypress' ) ?>';}" />
<input type="password" name="pwd" id="user_pass" value="" />
<input type="checkbox" name="rememberme" id="rememberme" value="forever" title="<?php _e( 'Remember Me', 'buddypress' ) ?>" />
<input type="submit" name="wp-submit" id="wp-submit" value="<?php _e( 'Log In', 'buddypress' ) ?>"/>
<?php if ( 'none' != bp_get_signup_allowed() &amp;amp;amp;&amp;amp;amp; 'blog' != bp_get_signup_allowed() ) : ?>
<input type="button" name="signup-submit" id="signup-submit" value="<?php _e( 'Sign Up', 'buddypress' ) ?>" onclick="location.href='<?php echo bp_signup_page() ?>'" />
<?php endif; ?>
<input type="hidden" name="redirect_to" value="<?php echo bp_root_domain() ?>" />
<input type="hidden" name="testcookie" value="1" />
<?php do_action( 'bp_login_bar_logged_out' ) ?>
</form>
So ,where to redirect is controllde by the line
<input type="hidden" name="redirect_to" value="<?php echo bp_root_domain() ?>" />
It is set to be redirected to the buddypress root site(you see the function bp_root_domain() )
Now let us make a small change there
replace the above one line in form code with this one
<input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI'];?>" />
Great ,save the changes,upload to your server and yeh,try logging in from profile page or any other page.
It will redirect you back there.
Just another step towards better user experience
I will love to hear from you ,did it work for you or not ?
If you enjoyed this post, make sure you subscribe to my RSS feed!We will keep coming with more informative tips,tricks,tutorials to keep you updated with wordpress/buddypress/wordpress mu regularly.If you want to help us,You can ,by spreading the words.We provide free and premium plugins/support for wordpress Mu,buddypress at a very low cost (starting with $30 for 3 months membership).If you or anyone you know,needs some real good plugins/themes for their wordpress Mu/buddypress powered site, Please refer them to http://BuddyDev.com.We will highly appreciate your support and keep coming with more useful and free stuffs.
Related posts:
- Tweaking the registration link at wpmu login page to point to buddypress registration page well,It is not that hard.If you are using buddypress and...
- Redirect your users to their profile ,when the login to your buddypress site hey, want to redirect your users to their profile when...
- Logout Redirect Plugin for wordpress mu/buddypress Here is our another free plugin bpdev-logout-redirect for buddypress and...
- Limit Number of Blogs per User for wordpress Mu and buddypress website/blog network Update 28th Feb, 2010: This plugin is updated, Please read...
- Make your users automatically logged in and redirect them to their profile when they create their account on your buddypress powered site I hope you might have used my plugin BP Auto...
Related posts brought to you by Yet Another Related Posts Plugin.

![[blinklist]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/blinklist.png)
![[Bloglines]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/bloglines.png)
![[del.icio.us]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/digg.png)
![[dzone]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/dzone.png)
![[Facebook]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/facebook.png)
![[Ma.gnolia]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/magnolia.png)
![[Mister Wong]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/misterwong.png)
![[Reddit]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/reddit.png)
![[Sphere]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/sphere.png)
![[Sphinn]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/sphinn.png)
![[StumbleUpon]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/technorati.png)
![[Email]](http://www.thinkinginwordpress.com/wp-content/plugins/bookmarkify/email.png)



Hi Brajesh. Now I’m conflicted
I’m using your plugin that redirects users to BP profile page upon login. Just have to make final decision before site is launched. Cheers.
hey mercime
Thanks for the comment. sorry I missed this as Hostgator has got some trouble and I am not getting comments by email.
Sorry for replaying late. Hope you have already made a decision by now