I think you get the idea to solve it but the code is not correct.
Try this.
// Get practice admin emails
function get_practice_admin_emails() {
$profile_admin_emails = array();
$args = array(
'role' => 'profile_admin',
);
$profile_admins = get_users( $args ); // this must be after $args
foreach ( $profile_admins as $user ) {
// try this instead
$profile_admin_emails[] = $user->user_email;
}
return $profile_admin_emails;
}
Explanation:
$args
must be beforeget_users( $args )
.- There was no assignment in this instruction
$profile_admin_emails[ $user->user_email ];
.