PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Querying Members in A Level

s2Member Plugin. A Membership plugin for WordPress®.

Querying Members in A Level

Postby cspowers » April 10th, 2011, 4:32 pm

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?
User avatar
cspowers
Registered User
Registered User
 
Posts: 13
Joined: April 10, 2011

Re: Querying Members in A Level

Postby Jason Caldwell » April 11th, 2011, 4:20 am

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
~ Jason Caldwell / Lead Developer
& Zeitgeist Movie Advocate: http://www.zeitgeistmovie.com/

Is the s2Member plugin working for you? Please rate s2Member at WordPress.org.
You'll need a WordPress.org account ( comes in handy ). Then rate s2Member here Image
.
User avatar
Jason Caldwell
Lead Developer
Lead Developer
 
Posts: 4045
Joined: May 3, 2010
Location: Georgia / USA

Re: Querying Members in A Level

Postby cspowers » April 11th, 2011, 7:08 am

Many thanks! That worked.
User avatar
cspowers
Registered User
Registered User
 
Posts: 13
Joined: April 10, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: No registered users and 1 guest

cron