Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: Login re-direct


Brajesh Singh
Participant

@sbrajesh

hi all,

Well,I had experimented with login feature and came up with another solution.I just blogged :) it and here is the code for your reference.

My goal was

1.redirect normal users to their profile,whether they try to login from front pages(yeh,site front page or any other page on site) or wp-login.php

2.If the user is Site admin, and logs from site front page,redirect him to front page

3.If User is Site admin and tries to login from wp-login.php,that means he is interested in login to wp-admin,so let him go to the mu dashboard.

here is the code you need to put in your bp-custom.php and It will handle it all for you.

add_filter("login_redirect","bpdev_redirect_to_profile",10,3);

function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user)
{
if(empty($redirect_to_calculated))
$redirect_to_calculated=admin_url();

/*if the user is not site admin,redirect to his/her profile*/
if(!is_site_admin($user->user_login))
return bp_core_get_user_domain($user->ID );
else
return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/

}

and No need to modify anything else.

Edit:I tried posting code twice ,hopefully the code is their in this post.

Skip to toolbar