Skip to content

Instantly share code, notes, and snippets.

@webpolk
Forked from jwenerd/friend-converter.php
Last active May 17, 2023 18:17
Show Gist options
  • Save webpolk/db79a452eb2ad73a9669 to your computer and use it in GitHub Desktop.
Save webpolk/db79a452eb2ad73a9669 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-site.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($initiator_user_id, $friend_user_id);
$follow->save();
if($is_confirmed == 1){
$follow = new BP_Follow($friend_user_id, $initiator_user_id);
$follow->save();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment