Hi there
I’m using PMPro with Buddypress and want to exclude members whose payment status is set to “pending” from appearing in the Buddypress members directory. I’ve seen various solutions posted by @brajesh for excluding various users (based on various criteria) from the members page but not sure which is most up-to-date/relevant.
I’ve also come across the code below which does exactly what I want for the PMPro members directory, so effectively I just want to apply something similar to the Buddypress members directory.
Any suggestions would be much appreciated.
With many thanks in advance.
Nikki`/*
Keep pending pay by check members from showing up in the member directory.
*/
function my_pmpro_member_directory_sql($sqlQuery, $levels, $s, $pn, $limit, $start, $end, $order_by, $order) {
global $wpdb;//only if pay by check is active
if(!function_exists(‘pmprobpc_isMemberPending’))
return $sqlQuery;//find pending members to exclude them
$pending_order_user_ids = $wpdb->get_col(“SELECT user_id FROM $wpdb->pmpro_membership_orders WHERE status = ‘pending’ GROUP BY user_id”);//check em
$pending_users = array();
foreach($pending_order_user_ids as $user_id) {
if(pmprobpc_isMemberPending($user_id))
$pending_users[] = $user_id;
}//update query
if(!empty($pending_users))
$sqlQuery = str_replace(“AND mu.membership_id”, “AND u.ID NOT IN(” . implode(“,”, $pending_users) . “) AND mu.membership_id”, $sqlQuery);return $sqlQuery;
}
add_filter(‘pmpro_member_directory_sql’, ‘my_pmpro_member_directory_sql’, 10, 9); `Hi Nikki,
Thank you for posting.Please use backticks(`) to share the code. I will be able to assist you once I see the code.
Regards
BrajeshHi Brajesh
Thank you for your reply. I actually thought I had used back ticks but fingers crossed will try again…
with many thanks in advance.
Nikki/* Keep pending pay by check members from showing up in the member directory. */ function my_pmpro_member_directory_sql($sqlQuery, $levels, $s, $pn, $limit, $start, $end, $order_by, $order) { global $wpdb; //only if pay by check is active if(!function_exists(‘pmprobpc_isMemberPending’)) return $sqlQuery; //find pending members to exclude them $pending_order_user_ids = $wpdb->get_col(“SELECT user_id FROM $wpdb->pmpro_membership_orders WHERE status = ‘pending’ GROUP BY user_id”); //check em $pending_users = array(); foreach($pending_order_user_ids as $user_id) { if(pmprobpc_isMemberPending($user_id)) $pending_users[] = $user_id; } //update query if(!empty($pending_users)) $sqlQuery = str_replace(“AND mu.membership_id”, “AND u.ID NOT IN(” . implode(“,”, $pending_users) . “) AND mu.membership_id”, $sqlQuery); return $sqlQuery; } add_filter(‘pmpro_member_directory_sql’, ‘my_pmpro_member_directory_sql’, 10, 9);
You must be logged in to reply to this topic.