Skip to:

Private Member?

  • Andrew Tegenkamp


    I was using the code example at and found it works great for removing users from the Member’s Directory list based on an xprofile field.

    However, when I change the order using the default Order By dropdown it seems the user that is removed comes back. I’m using the 2014 theme and default BP templates. Is there something else that needs to be done to get that to persist?

    Debug wise, I’ve tried add

    The POST source from Firebug below mentions a couple things about scope and filter but I’m not sure if that’s the place to look and why the action bp_before_directory_members doesn’t seem to fire on the Order By update:



Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp


    I don’t believe bp_parse_args() was available when I wrote that codex page.

    But you should use it instead; it should solve your issue:

    Andrew Tegenkamp


    Thanks, I got it fixed with this code (xprofile field id 2 = Yes) if it helps anyone else out.

    add_filter('bp_before_has_members_parse_args', 'get_custom_user_ids');
    add_filter('bp_get_total_member_count', 'custom_members_count');
    function get_custom_user_ids( $retval ) {
    	global $wpdb;
    	$custom_ids = $wpdb->get_col("SELECT user_id FROM {$wpdb->prefix}bp_xprofile_data WHERE field_id = 2 AND value = 'Yes'"); //print_r($custom_ids);
    	if ( !empty( $custom_ids ) ) $retval['include'] = $custom_ids;
    	return $retval;
    function custom_members_count ( $count ) {
    	$ids = get_custom_user_ids();
    	return count($ids); 

    Hopefully I’ll clean it up in a class but my first shot at that didn’t work out, but I’m sure that’s just me 🙂

    Thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar