Reply To: Need help combining bp_has_members() values to customize members loop
Hi @slaffik,
The code I am using on in my template is below. I am positive females are online as this is running on my local box and I have multiple female and male testing accounts that I am using for testing.
<?php
$user_ids = my_custom_ids( 'gender', 'female' );
if ( bp_has_members( array( 'type' => 'online', 'include' => $user_ids ) ) ) : ?>
Also, I am using the following (taken from the codex) in my functions.php to get these custom ids to work, just in case you need this. And I have verified custom ids are in fact working.
function my_custom_ids( $field_name, $field_value = '' ) {
if ( empty( $field_name ) )
return '';
global $wpdb;
$field_id = xprofile_get_field_id_from_name( $field_name );
if ( !empty( $field_id ) )
$query = "SELECT user_id FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id;
else
return '';
if ( $field_value != '' )
$query .= " AND value = '" . $field_value . "'";
/*
LIKE is slow. If you're sure the value has not been serialized, you can do this:
$query .= " AND value = '" . $field_value . "'";
*/
$custom_ids = $wpdb->get_col( $query );
if ( !empty( $custom_ids ) ) {
// convert the array to a csv string
$custom_ids_str = 'include=' . implode(",", $custom_ids);
return $custom_ids_str;
}
else
return '';
}
Really appreciate your help!
Best Regards,
Mark