A fresh mix of code snippets and tutorials

WordPress get all user emails

Quick snippet to get all user emails in WordPress.

<?php // WordPress get all user emails @ https://wp-mix.com/wordpress-get-all-user-emails/
$args = array('orderby' => 'display_name');
$wp_user_query = new WP_User_Query($args);
$authors = $wp_user_query->get_results();
if (!empty($authors)) {
	echo '<ul>';
	foreach ($authors as $author) {
		$author_info = get_userdata($author->ID);
		echo '<li>' . $author_info->user_email . '</li>';
	echo '</ul>';
} else {
	echo 'No results';
} ?>

Add to your theme and remix as needed.

See also: Get All User Email Addresses in WordPress

Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress