我的网站的移动版本位于mywebsite.com/mobile
还有一个登录表单wp-login.php
.
目前,当用户从主页登录时,如果他们不是管理员,则会重定向到他们的Buddypress配置文件
如果他们从主页登录,我希望保持此状态,但是,如果他们从mywebsite.com/mobile
, 我希望他们被重定向到mywebsite.com/mobile/dash
.
//REDIRECT USERS TO ACTIVITY PAGE WHEN THEY LOGIN
add_filter( "login_redirect", "bpdev_redirect_to_profile", 10, 3 );
function bpdev_redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user )
{
/* If logging in from website.com/mobile,
which has a login form which posts to wp-login.php,
redirect to website.com/mobile/dash
*/
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 );
/* If site admin or not logged in,do not do anything much */
else
return $redirect_to_calculated;
}