WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My team has inherited a large WordPress Networks install. Updates need to be run and we need to communicate this to our editors and administrators. My system admin has asked me for a list of URLs and email address matched to those URLs. We plan to contact them site-by-site to manage a system wide upgrade.

What would be an efficient way to go about this?

I can get a list of emails from the wp_users table. Is there a tool that does this already (and properly)?

Most importantly: How can I group these users to their individual WP sites in the Networks install?

In other words, how might I get a report like this from within the WP-Admin? My client would like to use a plug-in if possible to produce this report inside of the admin interface.

site one
- smellyPete
- bilboBaggins989 
site two
- sallysue997
- billyBob

etc, etc

share|improve this question
up vote 2 down vote accepted

This should do the trick. Read along with the comments for some explanation.

// get users with specified roles -- this can go in functions
function get_users_with_role( $roles ) {
    global $wpdb;
    if ( ! is_array( $roles ) )
        $roles = array_walk( explode( ",", $roles ), 'trim' );
    $sql = '
        SELECT  ID 
        FROM        ' . $wpdb->users . ' INNER JOIN ' . $wpdb->usermeta . '
        ON          ' . $wpdb->users . '.ID             =       ' . $wpdb->usermeta . '.user_id
        WHERE       ' . $wpdb->usermeta . '.meta_key        =       \'' . $wpdb->prefix . 'capabilities\'
        AND     (
    $i = 1;
    foreach ( $roles as $role ) {
        $sql .= ' ' . $wpdb->usermeta . '.meta_value    LIKE    \'%"' . $role . '"%\' ';
        if ( $i < count( $roles ) ) $sql .= ' OR ';
    $sql .= ' ) ';
    $sql .= ' ORDER BY display_name ';
    $userIDs = $wpdb->get_col( $sql );
    return $userIDs;

////// everything else could go in a custom page template just for viewing temporarily.

// poll database for users we need, using custom function (listed above)
$editors_and_admins = get_users_with_role(array('editor', 'administrator'));

// get user objects
$editors_and_admins = get_users(array('include' => $editors_and_admins);

echo '<table>';
// spit out as table - not sure what output you need. could easily create CSV by modifying this
foreach($editors_and_admins as $constituent){
    echo '<tr>'
    // get name
    echo '<td>'.get_the_author_meta('first_name', $constituent->ID).' '.get_the_author_meta('last_name', $constituent->ID).'</td>';
    // get email
    echo '<td><a href="mailto:'.$constituent->user_email'">'.$constituent->user_email.'</a></td>';
    // get URL
    echo '<td><a href="'.$constituent->user_url.'">'.$constituent->user_url.'</a></td>';
    echo '</tr>';
echo '</table>';
share|improve this answer

There's get_users() -- you could use it in conjunction with the results of a $wpdb query along the lines of $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );

function tell_all() {
    global $wpdb;
    $all_sites = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->blogs}" );
    $list = array();
    foreach( $all_sites as $site ) {
        $args = array(
            'blog_id' => $site,
            'fields' => 'user_email',
            'role' => 'Editor',
        $url = get_blogaddress_by_id( $site );
        $list[$url] = array();
        $editors = get_users( $args );
        $args['role'] = 'Administrator';
        $administrators = get_users( $args );
        $users = array_merge( $editors, $administrators );
        foreach( $users as $user ) {
            $list[$url][] = $user;


If I've got all that right, then at the end, $list should be an array of the format

$list = array(
    'site-1' => array( 
    'site-2' => array(



share|improve this answer
NB -- I'm not 100% sure if this will get only the Editors, or anyone with Editor and up. @GhostToast's answer looks to be somewhat more rigorous. – Pat J Jun 4 '13 at 20:30
not sure how mine will hold up in a multisite. Might need some modification to exist gracefully there. Never dealt with MU before. – GhostToast Jun 4 '13 at 20:33

Make backups before attempting anything.

Phpmyadmin, SQL tab, then: "Run SQL query/queries on database":

SELECT COUNT(*) AS Rows, user_login, user_email, user_nicename, user_url FROM wp_users GROUP BY user_login ORDER BY user_login

OR if you're not comfortable with SQL:

easy phpmyadmin export

Select wp_users

"Check All"

Query results operations


Then select MS Excel or CSV and further edit until you're left with user login, nicename, email, and user_url.

That should be sufficient enough to make contact

share|improve this answer

Pluin inadmin area

If you not want to use any script then you can use wordpress plugin Export Users to CSV.This can export ALL user data and meta data, and that works! You can even export the users by role and registration date range.


  1. Exports all users fields
  2. Exports users meta
  3. Exports users by role
  4. Exports users by date range
share|improve this answer

Initiate console/terminal

mysql -u username -p

USE wpdatabasename;

    `ID` ,
    `user_login` , 
    `user_nicename` , 
    `user_email` , 
    `user_url` , 
    `user_status` , 
FROM `wp_users` 
ORDER BY `user_email` DESC;

Analyze results

share|improve this answer
"This answer was automatically flagged as low-quality because of its length and content", which I am sure you don't want. Please explain what your code does in addition to posting the code. – s_ha_dum Jun 4 '13 at 22:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.