WordPress.org

Forums

Social Login
[resolved] Custom redirection with short code (5 posts)

  1. marlonsabala
    Member
    Posted 2 years ago #

    Hi chaps,

    since the automatic placement of the plugin on the registration page does not work I've placed it there with do_action('oa_social_login').

    The problem I have is that is redirects me back to the registration page.
    I know you can globally change where the short code of the plugin takes you. I have set it to "current page" since this makes sense in all the other calls for the short code around the site.

    So my question is: is it possible to add something to the short code to make it redirect some place specific, just for that placement?

    http://wordpress.org/extend/plugins/oa-social-login/

  2. Claude
    Member
    Plugin Author

    Posted 1 year ago #

    Hello,

    the following filters are available to customize the redirection:

    //Redirection for new users
    function oa_social_login_filter_redirect_for_new_users ($url, $user_data)
    {
    	//Force the url to something else
    	$url = 'http://my-website.com/welcome-new-user/';
    
    	//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://my-website.com/welcome-back/';
    
    	//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);

    The codes have to be added to the end of the functions.php file of your WordPress theme.

    Regards,

  3. blatan
    Member
    Posted 1 year ago #

    Hi Claude,
    I need a help.
    I used your above code. It works, but not in my case. I'm trying to redirect to user's profile edition (buddypress) to make him/her to fill all required fields.
    To do it I need to get user name.
    It works fine when user logs in normal way.
    But when I login via facebook I get empty current_user object and bp_user_id=0 as well.
    This way I get:
    http://websiteurl.com/profile/edit/group/1/
    from:
    $profile_path = $current_user->user_login . "/profile/edit/group/1/";
    In above $profile_url user name is empty.
    I added your filters. First I added with priority 10 as you did it, then I changed to 100 with hope it helps. I hoped later call of the filter allows another piece of code to be run first. Of course, it didn't help.

    What am I doing wrong?

    Is there any other action to be called right after registration/login?

    Regards,
    Bernard

  4. blatan
    Member
    Posted 1 year ago #

    There isone more option for me.
    Can I disable the redirecting actions?

  5. khushboo garg
    Member
    Posted 1 year ago #

    @blatan : I also wanted to redirect to user profile after oneall socila login completed.Please use the below code in your current theme function.php file

    /*** Forcing redirect to $_SESSION['specific_referer'] after registration & login in OneAll Social Login ***/
    add_filter('oa_social_login_filter_registration_redirect_url', 'my_login_registration_redirect_filter', 10, 2);
    add_filter('oa_social_login_filter_login_redirect_url', 'my_login_registration_redirect_filter', 10, 2);
    function my_login_registration_redirect_filter ($url, $user_data) {
        $url = site_url()."/members/".$user_data->data->user_nicename;
          return $url;
    }

    You are done !!! enjoy

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Social Login
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic