Forum Replies Created
-
@Henry and @Shanebp, I have a follow up question to this.
So this query ends up pulling up all the ID’s I want to include in the query, but as I’m getting close to launching my site and I’ve evaluated with my client the estimate of traffic that he expects I’ve come to wonder what the toll on the server will be when I have 5000, 10000 or 15000 users and the list of “include” or “exclude” is too long.
My biggest concern is that I’m having to do a double query for this. First, I have a query that gives me the IDs to include or exclude and then I pass that list to $qs = build_query($args);
Is there a way to actually alter the query, not just include/exclude IDs?
I think it would be easier if I could JOIN the query for subscribers with build_query().
Any thoughts?
I ended up using a tweaked version of Henry’s option:
function modify_loop_and_pag( $qs=false, $object=false ) { global $wpdb; if ( $object != 'members' ) // hide for members only return $qs; // create an array with my subscribed users $subscribers = $wpdb->get_results('SELECT user_id FROM wp_m_membership_relationships WHERE expirydate >= NOW( ) ' , ARRAY_N ); $args['include'] = ((!empty( $args['include'] )) ? $args['include'] . ',' : '') . ((empty($subscribers[0])) ? -1 : implode(',',$subscribers[0])); $qs = build_query($args); return $qs; } add_action( 'bp_ajax_querystring' , 'modify_loop_and_pag', 25, 2 );
Again, thanks for your help.. this opens a number of possibilities.
Best!
let me repost the MySql query.. that displayed terrible.
$subscribers = $wpdb->get_results('SELECT user_id FROM wp_m_membership_relationships WHERE expirydate >= NOW( ) ' , ARRAY_N );