Created
January 5, 2023 15:48
-
-
Save gioiliop7/081a926948efb388212645970f9f4be3 to your computer and use it in GitHub Desktop.
[PHP][WORDPRESS] Get users email by role
This file contains hidden or 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 | |
function get_users_email_by_role($role) | |
{ | |
$args = array( | |
'role' => $role, | |
); | |
$users = get_users($args); | |
$emails = array(); | |
foreach ($users as $user) { | |
$email = $user->user_email; | |
array_push($emails, $email); | |
} | |
return $emails; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment