WordPress.org

Ready to get started?Download WordPress

Forums

Social Login
[resolved] Redirect users to this page after they have logged in with Social Login embedded (7 posts)

  1. pwizard
    Member
    Posted 6 months ago #

    I have the widget on the sidebar, and set it up

    Redirect users back to the current page (Default)

    But users are going to their account dashboard. (as set up on the Login Page Settings where this is no option for current page (which makes sense on the login page of course)

    https://wordpress.org/plugins/oa-social-login/

  2. ypeynaud
    Member
    Posted 6 months ago #

    Hi @pwizard,

    I had the same issue and found the solution in Claude's answer in this post (through filters).

    Works fine for me, both for registration and login.

    Hope this helps,
    Yves.

  3. pwizard
    Member
    Posted 6 months ago #

    thanks for that. I had seen that post. Unfortunately, that code sends users back to specific pages. I want the current page, which of course will vary.

  4. ypeynaud
    Member
    Posted 6 months ago #

    You may want to use wp_get_referer() in this case.

    On my side, I also redirect on a dynamic uri. Since I have multiple cases and origins, I had to introduce the notion of Sessions. I use for this the Simple Session Support plugin, which works fine. I can then use the super-global $_SESSION array in which I simply set a new $_SESSION['specific_referer'] variable.

    I set this variable with the correct value, using wp_get_referer() or any other source, depending on my specific context. Then I use OneAll Social Login filters this <way:

    /*** 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)
    {
    	return $_SESSION['specific_referer'];
    }

    Btw, I also use this function in other redirect filters, since I rely upon Theme-my-Login and s2Member plugins, too.

    Cheers,
    Yves.

  5. khushboo garg
    Member
    Posted 5 months ago #

    @ypeynaud : Thanks It really works for me

  6. stephenblender
    Member
    Posted 3 months ago #

    Hi. Looking for this functionality myself, but having trouble. I am always redirecting back to my home page, which is the setting in the social login widget control panel. I have tried to override using the code below, but without any luck. It is based on the snippet above plus my own hacky bit. I have installed the simple session plugin.

    Any help appreciated!

    // return to page after login...hopefully
    /*** Forcing redirect to $_SESSION['specific_referer'] after registration & login in OneAll Social Login ***/
    function set_session_specific_referer()
    {
    	$Path=$_SERVER['REQUEST_URI'];
    	$URI='http://vitaminb12direct.com'.$Path;
    	$_SESSION['specific_referer'] = $URI;
    	echo "specific_referer:".$URI;
    }
    add_filter('wp_head', 'set_session_specific_referer');
    
    /*** 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)
    {
    	return $_SESSION['specific_referer'];
    }
  7. Denver
    Member
    Plugin Author

    Posted 3 months ago #

    Hello,

    you should start by checking if the filter is called and make sure it returns the good value.

    To debug you change your function like this:

    function my_login_registration_redirect_filter ($url, $user_data)
    {
    die($_SESSION['specific_referer']);
    	return $_SESSION['specific_referer'];
    }

    Do not forget to remove the die after having tested.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.