Redirect to author page on login?

edited April 2015 in WordPress
Hi.

I notice there's a filter that redirects both login and register to a certain url.
function oa_social_login_filter_redirect_for_new_users ($url, $user_data) { //Force the url to something else $url = 'http://www.google.com'; //New users will be redirected here return $url; } add_filter('oa_social_login_filter_registration_redirect_url', 'oa_social_login_filter_redirect_for_new_users', 10, 2); //Redirection for existing users function oa_social_login_filter_redirect_for_existing_users ($url, $user_data) { //Force the url to something else $url = 'http://www.google.com'; //Returning users will be redirected here return $url; } add_filter('oa_social_login_filter_login_redirect_url', 'oa_social_login_filter_redirect_for_existing_users', 10, 2);

I have individual member pages set up for each user when they register.
eg http://www.site.com/member/username

I would like to know how to forward it to these pages. I have a filter that does so on normal login/register which may be helpful but I can't seem to transfer the code over.

add_filter("login_redirect","redirect_to_profile",100,3); function redirect_to_profile($redirect_to_calculated,$redirect_url_specified,$user) { if(empty($redirect_to_calculated)) $redirect_to_calculated=admin_url(); if(!is_admin($user->user_login)) return get_author_posts_url($user->ID,$curauth->user_login); else return $redirect_to_calculated; }

Answers

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited April 2015
    You can use something like this:

    function oa_social_login_set_registration_redirect_url ($redirect_to, $user_data) { return 'http://www.site.com/member/'.$user_data->user_login.'/'; } add_filter('oa_social_login_filter_registration_redirect_url', 'oa_social_login_set_registration_redirect_url');
  • where you can put this code?

    i have the problem that redirections doesnt work. i put all to redirect to my homepage, but when doing the login with the plugin always get redirected to "my-profile" page...why? does this code can help me? in what file i can put it? thanks
  • Hi,
    This code should be placed in the functions.php or your Wordpress theme.
    You can edit this function via the administrator dashboard: Appearance \ Editor \ Theme Functions (functions.php).

    Hope this helps.

Welcome!

Please sign in to your OneAll account to ask a new question or to contribute to the discussions.

Please click on the link below to connect to the forum with your OneAll account.