This topic has 8 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #174448
     psmorrow
    Participant

    Hi there,

    I’m experiencing an issue that my login redirect code isn’t working on my site, but works just fine on localhost where i do my development.

    The only differences are my site has SSL and W3 Total Cache, which are not installed/configured on Localhost.  Everything else is the same.  I also have a ton of other custom code, which seems to work just fine.

     

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

    $user_id = $user->ID;

    //redirect to profile page

    $redirect_to = bp_core_get_user_domain($user->ID) . ‘profile/’;

    return $redirect_to;

    }

    add_filter(‘login_redirect’, ‘redirect_page’, 11, 3);

     

    Any thoughts about why could be happening?   Is it a caching issue?

    #174538
     Kieran_SQ
    Moderator

    Hi,

    I will assign this ticket to one of our developers to look into this for you.

    In the meantime please try disabling and clearing all caches as well as checking your PHP error log for hints. Please also consider this superb plugin which will do many kinds of different redirects for you https://wordpress.org/plugins/peters-login-redirect/.

    Thanks,

    Kieran

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Custom development requests can be sent to dev@seventhqueen.com, one of the development team will be happy to discuss your needs.

    #174736
     Radu
    Moderator

    Hi,

    The snippet that you are using looks good. I’m using the next code in kleo child theme and iti works as it should.

    COPY CODE
    
    function sq7_rdu_redirect( $redirect_to, $request, $user ) {
        $redirect_to = bp_core_get_user_domain($user->ID) . 'profile/';
        return $redirect_to;
    }
    add_filter('login_redirect', 'sq7_rdu_redirect', 11, 3);
    

    And also this

    COPY CODE
    
    function sq7_rdu_redirect( $redirect_to, $request, $user ) {
        $redirect_to = '/my-route-after-redirect/';
        return $redirect_to;
    }
    add_filter('login_redirect', 'sq7_rdu_redirect', 11, 3);
    

    try to change the 11 value to a higher or lower one… try also to remove all other your snippets and leave only this to test

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #174883
     psmorrow
    Participant

    Hi,
    Thanks for the reply. Sorry to say that I didn’t have any luck with:

    – increasing / decreasing priority (tried many different numbers from 0 to 999)
    – removed bp-custom.php from pluglins
    – removed all other code from functions.php
    – deactivated all plugins except for buddypress
    – cleared all cache, and disabled W3 Total Cache

    I have also verified that no errors are being logged in error_log….

    Any other suggestions on what else I can try?

    I’ll also experiment with Peters-login-redirect….

    Many thanks again for your help with this!

    #174960
     Radu
    Moderator

    That’s odd…

    Leave the w3 total cache de-activated while debugging, also de-activate object cache etc…

    I don’t know what can I advise you since those snippets work on my and on your side not…

    Try with peters redirect plugin instead.

    If you have cloudflare or something similar de-activate it while debugging (enable developer mode)

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #175037
     psmorrow
    Participant

    Also note, that this snippet doesn’t work either? Any connection you can think of?

    COPY CODE
    function action_bb_user_login ( $user_id ){
    	
    	$promo_field1 = xprofile_get_field_data( 'Earn a percentage of credits received by referrals', 1);	
    	$promo_field2 = xprofile_get_field_data( 'Points earned when you post content on forums', 1);	
    	$promo_field3 = xprofile_get_field_data( 'Points earned when you complete registration', 1);	
    
    	xprofile_set_field_data( 'Earn a percentage of credits received by referrals', $user_id, 100 );
    	xprofile_set_field_data( 'Points earned when you post content on forums', $user_id, 200 );
    	xprofile_set_field_data( 'Points earned when you complete registration', $user_id, 300 );
    	
    }
    
    add_action( 'bb_user_login', 'action_bb_user_login', 10, 1 ); 
    
    #175086
     Radu
    Moderator

    change priority (value 10) to a higher value or instead of using bb_user_login to use wp_login or wp_authenticate try those instead.

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #175310
     psmorrow
    Participant

    Hi Radu,

    I’m convinced that i’m not able to hook into any login / redirect / authentication WP/BP function. My theory is that its due to installing W3 Total Cache. I think it leaves code behind even when uninstalled.

    Quite unfortunate for me that I don’t have a backup prior to installing this plugin 🙁

    Would you consider installing this plugin and testing if you encounter any issues?

    Cheers!

    #175434
     Radu
    Moderator

    Hi,
    I cannot see any issue using W3 Total Cache and using the theme… if you still have the plugin active, it’s safe to de-activate the W3 Total Cache on live but purge/empty all caches before do it.

    Then just test your snippets if haves effect on the frontend but using an incognito window(not keeps browser cache.)

    Anyway, the snippets work on my end…and also on other users, maybe it’s an isolated issue? You can try to update the functions.php file from wp-admin -> theme options -> edit -> kleo-child -> functions.php maybe if you are using FTP client to edit in a dummy place… test it.

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 9 posts - 1 through 9 (of 9 total)

The forum ‘Plugins questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?