BuddyDev

Search

[Resolved] Prevent buddypress unfollow function for specified users

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

    Hello Brajesh,

    I use this code stated below to force users to follow a set of users upon registration. How can I prevent users from unfollowing this users with the stated IDs
    (Users should not be able to unfollow the stated users if possible to hide the unfollow button for the stated user IDs)

     function auto_follow_users( $user_id ){
    	if ( function_exists( 'bp_follow_start_following' ) ){
    
    	// Add your user ids here
    	$users_to_follow = array( '606', '617', '619', '608', '548' );
    
    		foreach ( $users_to_follow as $follow_user ) {
    			bp_follow_start_following( array( 'leader_id' => $follow_user, 'follower_id' => $user_id ) );			
    		}
    	}
    }
    add_action('bp_core_activated_user', 'auto_follow_users', 10, 1); 

    I would like to hide the unfollow button across the entire site for all this users with IDs ( ‘606’, ‘617’, ‘619’, ‘608’, ‘548’ )

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #14536

    Marking it closed in favour of
    https://buddydev.com/support/forums/topic/prevent-buddypress-unfollow-function-for-specified-users-2/

The topic ‘ [Resolved] Prevent buddypress unfollow function for specified users’ is closed to new replies.

This topic is: resolved