views:

110

answers:

3

How do I get an array or list of users in wordpress? I want to be able to store a new list of authors for permissions for a new plugin I'm working on.

A: 

This plugin selects from the users and usermeta tables. Looking at the source for it might be a good place to start.

gaustin
+3  A: 

Everytime you need to do something in Wordpress, is a good practice to check it's documentation, specially function and template tags references.

wp_list_authors is an example.

Displays a list of the blog's authors (users), and if the user has authored any posts, the author name is displayed as a link to their posts. Optionally this tag displays each author's post count and RSS feed link.

Since you want to manipulate the values from a template tag, you can use the echo parameter set to 0.

<?php $authors_list = wp_list_authors('show_fullname=1&optioncount=1&echo=0');?>
GmonC
Just a FYI... This just gives a bunch of syntax errors and fails the script...
Sakamoto Kazuma
Nvmd This Fails script because it is trying to print a list of authors not give me an array of authors.
Sakamoto Kazuma
+1  A: 

This will get you an array with users


$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$user = get_userdata($bloguser->user_id);
}
}
Michael