« Upgrading to MT4 | Main | MultiBlog and Upgrading to MT4 »

Get An Email List of All Authors On Your System

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>
        &lt;<mt:AuthorEmail />&gt;,
    </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>&lt;<mt:AuthorEmail />&gt;, </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.

Comments (5)

Hey Jesse, Could you do something similar to get a list of all the email addresses of people who have left comments on your blog?

Easy!

It's literally the same code, only you specify the role. I've updated the article to show the code.

Awesome, thanks Jesse!

Love the use for good not evil bit. ;-)

Elise and Jesse,

Thanks for this. I have a question: Where are you placing the code in your install, to get at the delimited list? Where is the output data retrieved?

Thanks! Gregg

I've tried creating an index template to hold the code, which worked for the blog author code, but the commenter code snippet did not return any results, even though I do have commenters with email addresses. Any help?

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)