Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
re: http://buddypress.org/support/topic/show-only-members-with-avatars-on-member-loop/
untested, but cleaned up...
/********* SEARCH MEMBERS BASED ON PROFILE FIELDS *********/
function gd_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 '';
$custom_ids = $wpdb->get_col( $query );
$user_ids_loop = array();
foreach ($custom_ids as $custom_id){
if(gd_check_avatar($custom_id)){
$user_ids_loop[] = $custom_id;
}
}
if ( !empty( $user_ids_loop ) ) {
// convert the array to a csv string
$custom_ids_str = 'include=' . implode(",", $user_ids_loop);
return $custom_ids_str;
}
else
return '';
}
/********* CHECK IF MEMBER HAVE AVATARS *********/
function gd_check_avatar($user_id){
// Check for avatar.
$avatarchk = false;
$userfbavatar = get_user_meta($user_id, 'facebook_uid', true);
if (!empty( $userfbavatar ) )
{
$avatarchk = true;
//echo "DEBUG: user has a FB photo<br/>";
}
elseif (bp_core_fetch_avatar( array( 'item_id' => $user_id, 'no_grav' => true,'html'=> false ) ) != bp_core_avatar_default() )
{
$avatarchk = true;
//echo "DEBUG: user has a photo<br/>";
}
return $avatarchk;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.