[wp-hackers] select all users with role X

Scott Merrill skippy at skippy.net
Tue Dec 27 03:12:06 GMT 2005


I'd like to send an email to all the users with the Administrator role.

Since the roles are stored as a serialized array in the usermeta table,
I need to iterate over the entire user table to find all the
administrators.  I _could_ cheat for the time being and use the
deprecated wp_user_level value, but that's just avoiding the issue.

In many circumstances, iterating over the user table won't be a big
deal, because the number of registered users is so small.  This is,
historically, because there is very little value for readers to become
registered users.  The newest version of my subscribe2 plugin is likely
to change that, and I suspect that some of my users are going to see
some reasonably large user lists.  Iterating over these to parse each
array of roles seems like a real waste of an RDBMS.

Short of re-working the roles and capabilities system, does anyone have
any tricks up their sleeves that might help?

Thanks,
Scott

-- 
skippy at skippy.net | http://skippy.net/

gpg --keyserver pgp.mit.edu --recv-keys 9CFA4B35
506C F8BB 17AE 8A05 0B49  3544 476A 7DEC 9CFA 4B35


More information about the wp-hackers mailing list