WordPress社交登录插件和URL重定向到用户配置文件



我正在使用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*/
    }
}
可以使用

以下代码访问Buddypress个人资料URL:

<?php 
$p= bp_loggedin_user_domain();
echo $p; 
?>

然后$p会将网址提供给登录用户的好友个人资料。

最新更新