Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: How to tell if a person has uploaded a avatar only once?


Tosh
Participant

@xberserker

Cool thank. I tried to upload 2 avatars. Still gives points. It gave an error with your original code. I just changed it slightly to this.

function my_bp_avatar_add_cppoints() {
global $bp;

$path = BP_AVATAR_UPLOAD_PATH . ‘/avatars/’ . $bp->loggedin_user->id;

$filecount = count(glob(“” . $path . “*.jpg”));

// this means that the user only has one avatar
if($filecount <= 2) {
if( function_exists(‘cp_alterPoints’) && is_user_logged_in() ){
cp_alterPoints(cp_currentUser(), get_option(‘bp_avatar_add_cp_bp’) );
cp_log(‘Avatar Uploaded’, cp_currentUser(), get_option(‘bp_avatar_add_cp_bp’), BuddyPress);
}
}
}
add_action(‘xprofile_avatar_uploaded’, ‘my_bp_avatar_add_cppoints’ );

Skip to toolbar