redirect function is not working with classipress theme

Hi All,
I am using the social login plugin with my classipress theme. I am trying to redirect all users logging in to their edit profile page.

I had successfully managed to redirect users logging with the normal login form using this code in functions.php

function redirect_to_dashboard( $redirect_to, $request, $user ) {

return home_url('/edit-profile');
}
add_filter( 'login_redirect', 'redirect_to_dashboard', 10, 3 );


For social login, I had updated the functions.php in my child them with this code. Users still are redirected to the home page.

function fix_redirect($redirect_to, $user_data)
{
return home_url('/edit-profile');
}

add_filter('oa_social_login_filter_registration_redirect_url', 'fix_redirect', 10, 2);
add_filter('oa_social_login_filter_login_redirect_url', 'fix_redirect', 10, 2);

Your help is really appreciated on how to fix / debug this.

Best Answer

  • Fred_PinelFred_PinelMember
    Answer ✓
    Hi,
    The following code seemed to work on a test site (is the 'edit-profile' specific to your site?):
    function fix_redirect($redirect_to, $user_data) { return get_edit_profile_url($user_data->ID); } add_filter('oa_social_login_filter_registration_redirect_url', 'fix_redirect', 10, 2); add_filter('oa_social_login_filter_login_redirect_url', 'fix_redirect', 10, 2);
    Also, you can skip all hooks, and set the complete URL in the plugin redirection settings, or didn't that work?

    Regards.

Answers

  • Hi,
    Maybe something like this:
    function redirect_to_dashboard_2( $redirect_to ) { return home_url('/edit-profile'); } add_filter( 'registration_redirect', 'redirect_to_dashboard_2', 10, 1);And without the oa_social_login_filter filters.

    Let us know!
  • Hi Fred,
    Thanks for your timely reply here. I had tried the code above, but it did not fix my problem. I believe oneall social login does not use loginredirect , registerredirect hooks?!

    PS. I have tried from both the registration form and login form with no luck.
  • Hi,
    Are you trying to redirect newly registered users, or users logging in?
    What redirection setting do you have in the Social Login plugin settings?
  • Hi Fred,
    I am trying to redirect in both scenarios.

    In the settings, I have redirection setting as: Redirect users to their account dashboard

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.