获取 WordPress 所有用户的电子邮件
来源:wordpress
作者:
2020-05-31
下面的代码可以帮你快速地将所有注册用户的电子邮件以列表的形式展示出来。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?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' ; } ?> |
可以将代码根据需要放在主题适当的位置上。