diff --git a/includes/Listeners/Jetpack.php b/includes/Listeners/Jetpack.php index eefa7618..9d388365 100644 --- a/includes/Listeners/Jetpack.php +++ b/includes/Listeners/Jetpack.php @@ -56,6 +56,7 @@ public function connected( $id, $secret, $is_public ) { array( 'id' => $id, 'public' => $is_public, + 'users' => array( $this, 'get_admin_users' ), ) ); } @@ -133,4 +134,31 @@ public function detect_plugin_activation( $plugin ) { update_option( 'jetpack_affiliate_code', $this->brand_code[ $brand ] ); } } + + /** + * Get Admin and SuperAdmin user accounts + * + * @return $users Array of Admin & Super Admin users + */ + private function get_admin_users() { + // Get all admin users + $admin_users = get_users([ + 'role' => 'administrator', + ]); + $users = []; + + // Add administrators to the $users and check for super admin + foreach ($admin_users as $user) { + $users[] = [ + 'id' => $user->ID, + 'username' => $user->user_login, + 'email' => $user->user_email, + 'name' => $user->display_name, + 'roles' => $user->roles, + 'super_admin' => is_super_admin($user->ID), + ]; + } + + return $users; + } }