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.
+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
2009-11-04 14:26:00
Just a FYI... This just gives a bunch of syntax errors and fails the script...
Sakamoto Kazuma
2009-11-16 15:16:19
Nvmd This Fails script because it is trying to print a list of authors not give me an array of authors.
Sakamoto Kazuma
2009-11-16 20:32:23
+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
2009-11-05 14:27:20