How to redirect to a specific page on initial login, and other page on all further logins?

Hiya,

I was wondering if it was possible to redirect a user when they first login on my site to a specific page.

I saw these options https://www.dropbox.com/s/afj8amc5e23gutx/Screenshot 2017-08-19 00.46.02.png?dl=0

But they refer to redirecting the user after they log in or register from the specific pages.

However, with this plugin, they can technically login on multiple pages, including blog posts.

What I'm specifically looking to do is if it's the first time they've ever logged in using their social network redirect them to Page A, and if they are logging in for the 2nd time or more, redirect to Page B.

I essentially want to take them to a 'thank you' type page when they first login with some details, but then not show them this again.

Thanks
Dale

Best Answer

  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    edited August 2017 Answer ✓
    Hi Dale,

    there are two filters that you can use. Here an example:

    // Applies the redirection filter to users that register using Social Login function oa_social_login_set_new_user_redirect_url ($url, $user_data) { return get_site_url(null, '/thank-you/'); } add_filter('oa_social_login_filter_registration_redirect_url', 'oa_social_login_set_new_user_redirect_url', 10, 2); // Applies the redirection filter to users that login using Social Login function oa_social_login_set_returning_user_redirect_url ($url, $user_data) { return get_site_url(null, '/welcome-back/'); } add_filter('oa_social_login_filter_login_redirect_url', 'oa_social_login_set_returning_user_redirect_url', 10, 2);

Answers

  • You legend!

    Thanks for the help.
  • Hi Claude,

    So I've gone ahead and added this to my child themes functions.php.

    Cleared my cache. Yet, when I log in, I'm still directed to my homepage.

    Am I missing something?

    // Applies the redirection filter to users that register using Social Login function oa_social_login_set_new_user_redirect_url ($url, $user_data) { return get_site_url(null, '/thanks-logging-facebook-please-read/'); } add_filter('oa_social_login_filter_registration_redirect_url', 'oa_social_login_set_new_user_redirect_url', 10, 2); // Applies the redirection filter to users that login using Social Login function oa_social_login_set_returning_user_redirect_url ($url, $user_data) { return get_site_url(null, '/dashboard/'); } add_filter('oa_social_login_filter_login_redirect_url', 'oa_social_login_set_returning_user_redirect_url', 10, 2);

    My site URL is www.firearmtrader.co.nz if you want to see it in action.
  • Claude_SchlesserClaude_SchlesserAdministratorOneAll Team
    Hi Dale,

    please open the Social Login settings in your WordPress admin area and make sure this option is set to NO:
    Allow other plugins to change the redirection url that you have chosen by using a hook/filter?

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.