简体   繁体   中英

WordPress Social Login Plugin and URL Redirect to User Profile

I am using the WordPress Social Login plugin. The settings require a url to be used for a redirect. This redirect in the settings work, but I am using BuddyPress and would like to redirect to the logged in users profile instead. There is no way thru the settings to have this happen.

I thought this code would work, but I don't seem to be using the correct filter. Can anyone offer any suggestions:

/*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 profile URL can be accessed by using the following code :

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

Then $p will give the url to buddypress profile of logged in user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM