


下面的代码可以帮你快速地将所有注册用户的电子邮件以列表的形式展示出来。
- <?php
- $args = array(‘orderby’ => ‘display_name’);
- $wp_user_query = new WP_User_Query($args);
- $authors = $wp_user_query->get_results();
- if (!emptyempty($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’;
- } ?>
可以将代码根据需要放在主题适当的位置上。
原文:WordPress get all user emails



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论