Skip to content

Instantly share code, notes, and snippets.

@matthewmcvickar
Last active February 14, 2019 22:31
Show Gist options
  • Save matthewmcvickar/e8db069de8bcac7ef868f8d39a63cc59 to your computer and use it in GitHub Desktop.
Save matthewmcvickar/e8db069de8bcac7ef868f8d39a63cc59 to your computer and use it in GitHub Desktop.
Output a CSV-formatted list of all Co-Authors Plus users
<?php
// N.B.: This probably only works on popula.com; I don't know what the Co-Authors Plus metadata situation is by default. ¯\_(ツ)_/¯
// Print a CSV-formatted list of all co-authors and their email addresses.
function output_all_coauthors_as_csv() {
$coauthors = get_posts(array(
'post_type' => 'guest-author',
'posts_per_page' => -1
));
echo 'Name,Email<br>';
foreach ($coauthors as $coauthor) {
// Uncomment the next line to only show the ones with email addresses:
// if ( empty(get_post_meta( $coauthor->ID, 'email', true ) ) ) { continue; }
echo esc_html( get_post_meta( $coauthor->ID, 'cap-display_name', true ) ) . ',' . esc_html( get_post_meta( $coauthor->ID, 'email', true ) ) . "<br>";
}
}
// Do it.
output_all_coauthors_as_csv();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment