[wp-hackers] select all users with role X
aaron at technosailor.com
Tue Dec 27 03:22:20 GMT 2005
On 12/26/05, Scott Merrill <skippy at skippy.net> wrote:
> 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?
Hmmmm... without iterating over the user table? Maybe create an item in
the options table with an array of user ids updated whenever a user is
added to the admin group? Would probably require a one time user table
scan when the plugin is installed to get all current admins and could be
added to after that.
I almost think iterating over the entire table would be more worthwhile,
but I don't know.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the wp-hackers