Skip to:
Content
Pages
Categories
Search
Top
Bottom

Get E-mail addresses of users without Photos?

  • Avatar of adamt19
    adamt19
    Participant

    @adamt19

    We’d like to encourage users who have not uploaded a custom profile photo.. to do so.

    I see threads related to bp_has_members calls, for displaying only users with photos in a member loop, but this isn’t really what we’re after, and I didn’t want to distract with my question on those threads.

    I’m looking for a SQL-only solution that returns e-mail addresses of users WITHOUT a custom photo, separated by commas for a mailing list. I can imagine this would also be very useful for other site administrators trying to increase engagement.

    Obviously if a user is using the default gravatar, their e-mail should not be included.

Viewing 1 replies (of 1 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    untested:

    
    function no_photos() { 
    	global $wpdb;
    
    	$emails = array();
    	
    	$ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->prefix}users" );
    
    	foreach( $ids as $id ) { 
    
    		$avatar_check = false;
       
    		if ( bp_core_fetch_avatar( array( 'item_id' => $id, 'no_grav' => true, 'html'=> false ) ) != bp_core_avatar_default() )
    			$avatar_check = true; 
    
    		if( ! $avatar_check ) { 
    			$email = $wpdb->get_var( "SELECT user_email FROM {$wpdb->prefix}users WHERE ID = $id" );
    			$emails[] = $email;
    		}
    	}
    		
    	$emails = implode(",", $emails);
    		
    	return $emails;
    		
    }
Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.