Skip to content

Instantly share code, notes, and snippets.

@jwenerd
Last active January 31, 2018 02:15
Show Gist options
  • Save jwenerd/71d22393a4d377fbfd21 to your computer and use it in GitHub Desktop.
Save jwenerd/71d22393a4d377fbfd21 to your computer and use it in GitHub Desktop.
<?php
// This script will convert
// all confirmed buddy press friends to mutual followers
// if their friendship is not confirmed then the
// requestor of the friendship becomes a follower
// of the requestee
$_SERVER['HTTP_HOST'] = 'your-sit.come';
ob_start();
include('/var/www/wordpressmu/wp-load.php'); //replace with your path to wordpress wp-load.php
ob_end_clean();
global $wpdb;
$sql = "SELECT * FROM wp_bp_friends"; // may need to repalce with your proper table prefix
$rows = $wpdb->get_results($sql, ARRAY_A);
foreach($rows as $row){
// print_r($row);
extract($row);
$follow = new BP_Follow();
$follow->bp_follow($initiator_user_id, $friend_user_id);
$follow->save();
if($is_confirmed == 1){
$follow = new BP_Follow();
$follow->bp_follow($friend_user_id, $initiator_user_id );
$follow->save();
}
}
@vikramshaw
Copy link

Can anyone tell me where to paste this code so that my buddypress friends can be converted to followers

@darrindevs
Copy link

I'd also like to know where to put this code. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment