Why Does this Hook Not Working?

edited June 2015 in Questions
Hello,

I'm using a plugin called BuddyPress Follow and I'm trying to utilize a function that automatically sets all new users to follow my main administrator account.

function oa_social_login_auto_follow($user_data){

if(function_exists('bp_follow_start_following')){

// Add your user ids here
$users_to_follow = array('1');

foreach ( $users_to_follow as $follow_user ) {
bp_follow_start_following( array( 'leader_id' => $follow_user, 'follower_id' => $user_data->id ) );

// If you don't want them to follow back remove the line below
// bp_follow_start_following( array( 'leader_id' => $user_data->id, 'follower_id' => $follow_user ) );
}
}

}

add_action('oa_social_login_action_after_user_insert', 'oa_social_login_auto_follow', 10, 1);


Why is this not working? There is nothing wrong with the bp_follow_start_following function as it works when I hook into the BP New User Activation. If I echo out $user_data->id I get the correct value so why is no new following association being created correctly? I have also tried changing the priority from 10 to 1 but that still did not work.

Answers

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.