Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Member Loop only MemberPress members

@rsmithgs

Participant

Thank you so much! In case you couldn’t tell I’m not that familiar with accessing the database.

This completely worked, just in case anyone needs this for the future here is what I used:

<?php //get ids of members I want to include by grabbing members from db
$memberPressMembers = $wpdb->get_col("SELECT DISTINCT user_id FROM wp_mepr_transactions WHERE status IN('confirmed','complete') AND (expires_at >= NOW() OR expires_at = '0000-00-00 00:00:00')");

$include_string = '&include=' . implode(", ", $memberPressMembers); 
//print out array of IDs to console to find how many people we are getting
//echo '<script>console.log(' . json_encode($memberPressMembers, JSON_HEX_TAG) . ');</script>';
?>

<?php if ( bp_has_members( bp_ajax_querystring( 'members' ). $include_string ) ) : ?>

I didn’t actually need product id, because I want anyone who has an active membership to appear here, but be careful about a lot of “OR” statements as this could lead to grabbing people who also have a pending transaction as well (displaying people with pending but not complete transactions). If you want specific memberships I would probably add

AND product_id IN (MEMBERSHIPIDs)

Thanks again for all of your help @shanebp!

Skip to toolbar