Created
January 11, 2016 16:28
-
-
Save eighty20results/fab5e197ead44fd3972c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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