Page 1 of 1

Querying Members in A Level

PostPosted: April 10th, 2011, 4:32 pm
by cspowers
Greetings,

I'm very new to WP and S2 Member. Currently using the free version but am planning up going with S2 Member Pro.

I want to create a "page of posts" using a fairly standard version of the loop. But what I want to accomplish is that the page of posts contains only the posts that are _authored_ by members of a particular level.


Code: Select all
$leaderlist = S2functionhere("LeaderLevel");
//diyc
$args = array(
   'orderby' => 'date',
   'order' => 'DESC',
   'paged' => $paged,
   'author' => $leaderlist, //diyc
);
$wp_query = new WP_Query($args);


What's the best way to build a list of IDs of users in a particular level?

Re: Querying Members in A Level

PostPosted: April 11th, 2011, 4:20 am
by Jason Caldwell
Thanks for the excellent question.

You might try something like this.
Code: Select all
<?php
$array 
= array ();

foreach (get_users ("role=s2member_level1") as $user)
    $array[] = $user->ID;

$leaderlist = implode (",", $array);

$args = array ("orderby" => "date", "order" => "DESC", "paged" => $paged, "author" => $leaderlist);

$wp_query = new WP_Query ($args);
?>
Reference article: http://codex.wordpress.org/Function_Reference/get_users

Re: Querying Members in A Level

PostPosted: April 11th, 2011, 7:08 am
by cspowers
Many thanks! That worked.