我正在使用 WordPress 社交登录插件。这些设置需要一个用于重定向的 url。设置中的此重定向有效,但我正在使用 BuddyPress 并希望重定向到登录的用户配置文件。没有办法通过设置来发生这种情况。
我认为这段代码可以工作,但我似乎没有使用正确的过滤器。任何人都可以提供任何建议:
/*Add a filter to filter the redirect url for login with wordpress social login*/
add_filter('wsl_process_login_get_redirect_to','bpdev_redirect_to_profile',100,3);
add_filter('login_redirect','bpdev_redirect_to_profile',100,3);
function bpdev_redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user {
/*if no redirect was specified,let us think ,user wants to be in wp-dashboard*/
if(empty($redirect_to_calculated)) {
$redirect_to_calculated=admin_url();
}
/*if the user is not super admin,redirect to his/her profile*/
if(!is_super_admin($user->user_login)) {
return apply_filters('bpdev_login_redirect_url',bp_core_get_user_domain($user->ID ),$user->ID);//allow top redirect at other place if they want
} else {
return $redirect_to_calculated; /*if site admin or not logged in,do not do anything much*/
}
}