Last active
April 17, 2023 00:42
-
-
Save KaineLabs/16993b4f62996a5082bea6a935a0d9f3 to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Make all Users Friend With Admin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Youzify - BuddyPress Make all Users Friend With Admin | |
* **/ | |
function yzc_make_all_accounts_friend_with_admin() { | |
$option_name = 'yzc_make_all_admin_friends'; | |
if ( ! get_option( $option_name ) && bp_is_active( 'friends' ) ) { | |
// Admin ID | |
$accounts = array( 1, 2 ); | |
// Get All users Id's | |
$users = get_users( array( 'fields' => 'id', 'exclude' => $accounts ) ); | |
foreach ( $users as $user_id ) { | |
foreach ( $accounts as $account_id ) { | |
friends_add_friend( $account_id, $user_id, true ); | |
} | |
} | |
update_option( $option_name, 1 ); | |
} | |
} | |
add_action( 'init', 'yzc_make_all_accounts_friend_with_admin' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment