Redirection does not work with social login. Looking for some suggestions of what to try.

Hello,

I have installed oneall on WordPress, and am testing the plugin with one social integration so far ... Facebook.

Everything works, as far as register/login, and email notifications, however, when I login the page just redirects to the dashboard. It doesn't matter what I set redirection to ... it only goes to the dashboard.

I disabled all of my other plugins, and this issue is still happening.

Is there an issue with the plugin itself?

Any suggestions would be great.

Thanks!

Answers

  • Just an FYI ... I found some code in one of your other support posts, and got some feedback within my error log. Here it is:

    [18-Aug-2016 22:39:52 UTC] oa_social_login_action_before_user_redirect ARG: http://vwh.mediasteadbeta.com/wp-admin/

    I set my redirect to "/my-account", and it is still going to the dashboard.

    Thanks!
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited August 2016
    Hi Michael,

    could you please try this.

    Open the file communication.php of the plugin and locate the following line:
    https://github.com/oneall/social-login-wordpress/blob/master/oa-social-login/includes/communication.php#L497

    Then add this code
    $redirect_to = home_url ();

    Just above
    //Use safe redirection

    Please tell me if you are then redirected to the homepage.
  • edited August 2016
    Claude,

    I tried your solution, and it did not work.

    Actually, I spoke too soon .... your solution did work, however, please read below:

    I don't want to hard code a solution, as this poses two problems.

    First, when an update is released, my solution will be overwritten.

    Second, I would like to be able to use the settings within the plugin to decide what type of redirection I want at any given point.

    Please advise.

    Thanks!
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hi Michael,

    the change that I asked you to do was not intended to be the solution. It only helped me discover where the problem actually is.

    In our plugin we have this line:
    $redirect_to = apply_filters ('login_redirect', $redirect_to, (! empty ($_GET ['redirect_to']) ? $_GET ['redirect_to'] : ''), $user_data);

    This applies any filters that you might have for the login url to it. My change in fact skips those filters, which shows us that something in your blog (probably a plugin) is using this filter to modify the redirect url and to send user to the dashboard.

    We often see this kind of issue. What we will add to the plugin is a checkbox to enable/disable the filters.

  • Claude,

    I disabled all plugins, and this issue still occurs, so I can't see how the filter is being modified.

    Have you tested the most recent version locally? Are you able to use all of the redirect settings in the plugin?

    Thank you for your reply. Will you be providing me with a solution to this issue, or are you considering this support post closed?

    I look forward to hearing from you.
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited August 2016
    Hi Michael,

    could you copy/paste this code to the end of your functions.php file?

    add_action( 'wp_footer', 'list_filters' ); function list_filters() { global $wp_filter; $comment_filters = array (); $h1 = '<div style="background-color:#fff!important;"><h1>Current Filters</h1>'; $out = ''; $toc = '<ul>'; foreach ( $wp_filter as $key => $val ) { if ( FALSE !== strpos( $key, 'login_redirect' ) ) { $comment_filters[$key][] = var_export( $val, TRUE ); } } foreach ( $comment_filters as $name => $arr_vals ) { $out .= "<h2 id=$name>$name</h2><pre>" . implode( "\n\n", $arr_vals ) . '</pre>'; $toc .= "<li>$name</li>"; } print "$h1$toc</ul>$out</div>"; }

    This will displayed the filters.

    Yes, we have tested the last version.
    I will now make a few more tests and add an option to disable the filters.

    Regards,
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hi Michael,

    here a new version of Social Login:
    https://www.dropbox.com/s/kbhg8fit1wbrazz/wordpress---oneall-social-login.zip?dl=0

    Simply deactivate/remove the current version then upload and activate this version.

    You will then find these options "Allow other plugins to change the redirection url that you have chosen by using a hook/filter?" that you can activate in order to protect the redirection.
  • Hi,
    What is odd is that the /my-account is also a URL with a login form.
    Could you try to redirect to another custom URL besides /my-account (to try) ?

    Regards
  • Thanks for the reply! I apologize for not getting back sooner. My client put a temporary hold on the project. We are getting started again today, so I'll test everything and let you know how we make out.

    FYI, I tested the social login on a clean install, and it was still not working, but I will test everything again, so we can get to the bottom of it.

    Cheers!
  • @Claude_Schlesser, I am sorry to say that the custom version of the plugin you provided does not work.

    I just tested the plugin on a completely fresh database, using a default WordPress theme, with no other plugins install ... just oa-social-plugin, and the redirecting does not work.

    I redirected to the default "Hello World" blog post, and instead, I am redirected to "wp-admin" dashboard.

    Also, for your information, I ran the test on my clean install:

    I put $redirect_to = home_url (); above //Use safe redirection ...

    This above test redirected me to the homepage.

    Can you please test this on your own fresh install to see if you can duplicate my issues?

    Thanks!

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hello,

    for me it works without any issues.
    Could you please post a screenshot of your Social Login redirection settings?

    Regards,
  • edited September 2016
    @Claude_Schlesser,

    I'm not sure what this screenshot is going to tell you, but here it is.

    Like I said ... I have a fresh install of WordPress, and the redirection is not working. It surprises me that it is working for you under the same circumstances.

    Please advise as to what you think the next step should be. I really need this to work, otherwise, I am going to have to choose another solution and move on, as this is taking quite some time to figure out.

    Thanks.


    image
  • @Claude_Schlesser,

    Just as a point of reference, I just created a brand new database, and install a brand new WordPress install.

    I did nothing to the fresh install. Everything was left default in your plugin. The only thing I changed was the custom redirection, and it did not work.

    The only thing I can think is that there is something wrong with the plugin. There are no conflicting factors that should break this functionality.

    You said that it works on your fresh install. Can you share your settings with me?

    Is there a setting in the OneAll dashboard that needs to be configured?

    Is there a setting in the Facebook App that needs to be configured?

    I am honestly trying to figure out if there is anything else that could be causing this issue, but the fact that it doesn't work on such a fresh and clean install concerns me.

    Thanks so much for your continued support. I look forward to your reply.

    Hopefully we can figure this out withing the next day or so, because I need to move on with this project :-(

    Cheers!
  • @Claude_Schlesser,

    After much research, I found this in another one of your support posts. It's not ideal, but it works for now. If you can, please continue to work with me on a solution where your custom redirect in the settings section works, I'd appreciate it.

    I am considering this a temporary solution:
    //Redirection for new users
    function oa_social_login_filter_redirect_for_new_users ($url, $user_data)
    {
    //Force the url to something else
    $url = 'http://vwh.mediasteadbeta.com/my-account/';

    //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://vwh.mediasteadbeta.com/my-account/';

    //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 am also experiencing a similar result except the redirect never resolves. I turned off all my plugins except social and it acts the same. FB, Pinterest... all success with the login then frozen state of
    You have logged in with Pinterest
    Please wait, you are being redirected ...
    Michael, did you place this in the functions.php?
    Thanks for sharing your research
  • Hi There Team!

    I have a similar problem. I am using the latest version of vBulletin Connect 5 and I am only using the LinkedIn social log in. After logging in, the page goes blank and does not redirect. Furthermore, if I go back in the browser I am not logged in despite a message in between stages which says 'You have been logged in, you are now being redirected.'

    My site is here.
    My Site

    Please kindly advise.

    Many thanks in advance.

    Kind Regards,
  • @Michael_Rapino
    Basic testing does work, so something is odd here.

    Maybe there is a custom list of whitelisted hosts for your site ? (if so, and the site is not whitelisted, then it redirects to wp-admin, which reminds me of your problem).
    Check for filters on 'allowed_redirect_hosts' in your theme's functions file, or in any other plugin.

    Hope this helps.
  • @Fred_Pinel ... I have done most of my testing on both a live server, as well as localhost. Nothing works. A brand new install with OneAll as the only plugin on my local machine, and it still doesn't work. I am using the default theme in the local test, there is absolutely nothing custom, just the out of the box WP with only this plugin. I am absolutely out of ideas.
  • Fred_PinelFred_PinelMember
    edited September 2016
    Hi,
    For @Jerry_Jaz, Nom26, could you please open a new discussion?
    Yes, the code was added to functions.php.

    Thanks!
  • Hi,
    Just a thought, were you using the shortcode or widget on the my-account page? (if so, the redirect settings are specific)

  • I'm sorry, there may have been a miscommunication. I am using the default social login on the regular WP login screen. I was trying to redirect to a custom page I created called my-account.

    However, in my tests on localhost, I chose to install a brand new fresh install of WP, and use the default theme. There are no other plugins installed, and the redirect still didn't work. In this test I just redirected to a regular page.

    I used a workaround, so I could move on with my project, but it would be nice to complete this support discussion with a resolution for anyone else having this issue.

    Thanks for your patience.

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.