Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function pmpro_my_get_paying_member_ids()
{
global $pmpro_levels;
global $wpdb;
$user_ids = array();
$paying_levels = array();
foreach( $pmpro_levels as $level ) {
$cost = $level->initial_payment + $level->billing_amount + $level->trial_amount;
// Find membership level(s) that require some sort of payment.
if ( (float)$cost > 0.00 ) {
$paying_levels[] = $level->id;
}
}
// Grab all user IDs for users who have paying membership levels.
$user_sql = $wpdb->prepare("
SELECT u.ID AS id
FROM {$wpdb->users} as u
INNER JOIN {$wpdb->pmpro_memberships_users} as m
ON (m.user_id = u.ID)
AND m.id IN (%s)
AND m.status = 'active'",
explode(",", $paying_levels)
);
$users = $wpdb->get_results($user_sql);
foreach( $users as $u ) {
$user_ids[] = $u->id;
}
return $user_ids;
}
function my_bp_set_args_for_bp_query($args)
{
$args['include'] = pmpro_my_get_paying_member_ids();
return $args;
}
add_filter('bp_member_with_uploaded_avatar_query_args', 'my_set_args_for_bp_query', 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.