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

时间:2013-11-05 06:09:03

标签: wordpress redirect profile buddypress

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

1 个答案:

答案 0 :(得分:1)

可以使用以下代码访问Buddypress配置文件URL:

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

然后$ p会将URL记录给登录用户的buddypress个人资料。