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
You should perhaps not need this if the OneAll registration process follows the BuddyPress registration, as indicated in:
support.oneall.com/forums/discussion/1909/no-activation-email-after-registration#latest.
Hope this helps.