This article was first published at Movable Tweak.
This little snip of code will dump out a list of all the users and their email addresses on your install in a comma-delimited format that you can easily import into your email client. It’s particularly useful on larger installs:
<mt:Authors include_blogs="all"> <mt:IfNonEmpty tag="AuthorEmail"> <mt:IfNonEmpty tag="AuthorDisplayName">"<mt:AuthorDisplayName />" </mt:IfNonEmpty> <<mt:AuthorEmail />>, </mt:IfNonEmpty> </mt:Authors>
And the Authors tag allows for all sorts of cool filtering attributes so you can get at any group of authors in the system, ordered however you like:
- display_name: Specifies a particular author to select.
- lastn: Limits the selection of authors to the specified number.
- sortby: Supported values: displayname, name, created_on.
- sort_order: Supported values: ascend, descend.
- roles: comma separated list of values. eg “Author, Commenter”
- need_entry: 1 | 0 (default is 1)
- status: Supported values: enabled, disabled. Default is enabled.
Note: Some people have asked about creating an email list of all the commenters on the system, and it’s very simple. The code stays the same, but you just need to specify roles=”Commenter” and need_entry=”0” (since most commenters won’t have written an entry). Here’s the code to do it:
<mt:Authors include_blogs="all" roles="Commenter" need_entry="0" sort_by="display_name"><mt:IfNonEmpty tag="AuthorEmail"><mt:IfNonEmpty tag="AuthorDisplayName">"<mt:AuthorDisplayName />" </mt:IfNonEmpty><<mt:AuthorEmail />>, </mt:IfNonEmpty> </mt:Authors>
Notice the code is much more compressed than the code given previously. If you tried the previous code, you probably noticed that the spacing is crazy because of all the hard returns and spaces we have in there. This second set of code I posted will give you a highly compact list of email addresses than can literally be copied and pasted into an email client.
Just make sure you use this for good, not evil.