BuddyDev

Search

[Resolved] BuddyPress Auto Friendship Pro Adjustment

  • Keymaster
    (BuddyDev Team)
    Posts: 24645
    Brajesh Singh on #38296

    Hi Tosin,
    Can you please re-state the issue. I will like to take care of it myself. Please be specific on what is the issue you are facing wand what do you expect it to work like.

    Is it the first login not making auto follow ?

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38317

    Hello Tosin,

    Sorry for the delayed reply. Please try the following code on priority 11 instead of -1

    
     /**
     * Redirect New Users On first and second login
     *
     * @param string  $user_login User login.
     * @param WP_User $user       User object.
     *
     */
    function buddydev_redirect_on_first_login( $user_login, $user ) {
    
    	if ( ! function_exists( 'buddypress' ) ) {
    		return;
    	}
    	// check for user's last activity.
    	$last_activity = bp_get_user_last_activity( $user->ID );
    
    	if ( empty( $last_activity ) ) {
    		update_user_meta( $user->ID, '_buddydev_first_login', 1 );
    		// Redirect you custom page.
    		bp_core_redirect( bp_get_root_domain() . '/welcome' );
    	} elseif ( get_user_meta( $user->ID, '_buddydev_first_login', true ) ) {
    		delete_user_meta( $user->ID, '_buddydev_first_login' );
    		// Try second login here.
    		bp_core_redirect( bp_get_root_domain() . '/publish' );
    	}
    }
    add_action( 'wp_login', 'buddydev_redirect_on_first_login', 11, 2 );
    
    

    Please do let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38318

    The code by Ravi stopped working, I don’t have any problem with the former code the issue is first login does not auto follow.


    @sbrajesh
    the basic problem i’m facing is first login is not making auto follow

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24645
    Brajesh Singh on #38319

    Hi Tosin,
    can you please disable the custom redirect plugins/code and then test if it works or not? My team’s guess is that you have a redirect at higher priority causing it and we need to confirm that asusmption.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38329

    Hello conflict detected

    1. The code provided by Ravi solved part of the problem, the priority (11) worked.
    2. The second problem was caused by buddypress profile completion plugin which I deactivated.

    While using profile completion plugin I have this filter enabled

    // filter buddypress profile completion redirect url to a custom page.
    add_filter( 'buddypress_profile_completion_redirect', function ( $redirect_url ) {
    	return get_permalink( 34168 );
    } );

    Then I need the code below to take priority over the redirect of buddypress profile completion plugin for newly registered users.

     function buddydev_redirect_on_first_login( $user_login, $user ) {
    
    	if ( ! function_exists( 'buddypress' ) ) {
    		return;
    	}
    	// check for user's last activity.
    	$last_activity = bp_get_user_last_activity( $user->ID );
    
    	if ( empty( $last_activity ) ) {
    		update_user_meta( $user->ID, '_buddydev_first_login', 1 );
    		// Redirect you custom page.
    		bp_core_redirect( bp_get_root_domain() . '/welcome' );
    	} elseif ( get_user_meta( $user->ID, '_buddydev_first_login', true ) ) {
    		delete_user_meta( $user->ID, '_buddydev_first_login' );
    		// Try second login here.
    		bp_core_redirect( bp_get_root_domain() . '/publish' );
    	}
    }
    add_action( 'wp_login', 'buddydev_redirect_on_first_login', 11, 2 ); 

    Thanks for your patience

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38346

    Hello Tosin,

    Thank you for the acknowledgment. I am glad that the problem is resolved.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38348

    Hello Ravi

    The conflict is detected but the problem is not resolved as I still have buddypress profile completion plugin deactivated, if I activate it, the problem will occur again as I still want to use the buddypress profile completion plugin.

    I still need buddypress profile completion plugin, auto friendship and the custom code to work together without any conflict

    Thanks

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38349

    Hello Tosin,

    Okay, Please let me know which one is the issue now i.e. Is it a redirection issue? or Auto following.

    PS: https://buddydev.com/support/forums/topic/buddypress-auto-friendship-pro-adjustment/page/3/#post-38329 in the first point you had mentioned that issue is working. I am assuming you were talking about auto-following issue.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #38350

    The auto follow on first login works when buddypress profile completion is deactivated.

    The issue is that auto follow on login will not work when buddypress profile completion plugin is active.

    But your custom redirect code works with the auto follow when the priority is at (11) only buddypress profile completion plugin prevents auto follow to work when its active

    This is how the priority level should be
    1. Autofollow on first login (first priority)
    2. Custom redirect code for new user (second priority – this should have priority over buddypress profile completion )
    3. buddypress profile completion (last priority)

    PS: buddypress profile completion and auto follow on login do not work together when both are active

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #38378

    Hello Tosin,

    I will look into it and will update you soon.

    Regards
    Ravi

The topic ‘ [Resolved] BuddyPress Auto Friendship Pro Adjustment’ is closed to new replies.

This topic is: resolved