2013-11-05 97 views
1

我正在使用WordPress社交登錄插件。這些設置需要一個url用於重定向。此設置中的重定向工作正常,但我使用的是BuddyPress,並且希望重定向到登錄的用戶配置文件。有沒有辦法通過設置發生這種情況。WordPress社交登錄插件和URL重定向到用戶配置文件

我認爲這段代碼可以工作,但我似乎沒有使用正確的過濾器。任何人都可以提出任何建議:

/*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

BuddyPress的個人資料網址可以使用下面的代碼來訪問:

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

然後$ P會給網址的登錄用戶BuddyPress的個人資料。

相關問題