/** * Start following a user's activity. * * @since 1.0.0 * * @param array $args { * Array of arguments. * @type int $leader_id The user ID of the person we want to follow. * @type int $follower_id The user ID initiating the follow request. * } * @return bool */ function bp_follow_start_following($args = '') { global $bp; $r = wp_parse_args($args, array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id())); $follow = new BP_Follow($r['leader_id'], $r['follower_id']); // existing follow already exists if (!empty($follow->id)) { return false; } if (!$follow->save()) { return false; } do_action_ref_array('bp_follow_start_following', array(&$follow)); return true; }
/** * Start following a user's activity. * * @since 1.0.0 * * @param array $args { * Array of arguments. * @type int $leader_id The user ID of the person we want to follow. * @type int $follower_id The user ID initiating the follow request. * } * @return bool */ function bp_follow_start_following($args = '') { global $bp; $r = wp_parse_args($args, array('leader_id' => bp_displayed_user_id(), 'follower_id' => bp_loggedin_user_id(), 'follow_type' => '', 'date_recorded' => bp_core_current_time())); $follow = new BP_Follow($r['leader_id'], $r['follower_id'], $r['follow_type']); // existing follow already exists if (!empty($follow->id)) { return false; } // add other properties before save $follow->date_recorded = $r['date_recorded']; // save! if (!$follow->save()) { return false; } // hooks! if (empty($r['follow_type'])) { do_action_ref_array('bp_follow_start_following', array(&$follow)); } else { do_action_ref_array('bp_follow_start_following_' . $r['follow_type'], array(&$follow)); } return true; }