
下面的代码可以帮你快速地将所有注册用户的电子邮件以列表的形式展示出来。
- <?php
- $args=array(‘orderby’=>‘display_name’);
- $wp_user_query=newWP_User_Query($args);
- $authors=$wp_user_query->get_results();
- if(!emptyempty($authors)){
- echo‘<ul>’;
- foreach($authorsas$author){
- $author_info=get_userdata($author->ID);
- echo‘<li>’.$author_info->user_email.‘</li>’;
- }
- echo‘</ul>’;
- }else{
- echo‘Noresults’;
- }?>
可以将代码根据需要放在主题适当的位置上。
原文:WordPress get all user emails



