Re: How to tell if a person has uploaded a avatar only once?
I tried this as well. Not the desired outcome.
if ( !$no_grav ) {
Went back to this, because I’m sure I am getting closer .. When I test this with an account has an existing avatar, it still gives me points.
// Avatar Anti-Spam
global $bp;
$avatar_dir = ‘avatars’;
$avatar_dir = apply_filters( ‘bp_core_avatar_dir’, $avatar_dir, $object );
$item_id = $bp->displayed_user->id;
$object = ‘user’;
$avatar_folder_url = apply_filters( ‘bp_core_avatar_folder_url’, str_replace( WP_CONTENT_DIR, BP_AVATAR_URL, BP_AVATAR_UPLOAD_PATH ) . ‘/’ . $avatar_dir . ‘/’ . $item_id, $item_id, $object, $avatar_dir );
$avatar_folder_dir = apply_filters( ‘bp_core_avatar_folder_dir’, BP_AVATAR_UPLOAD_PATH . ‘/’ . $avatar_dir . ‘/’ . $item_id, $item_id, $object, $avatar_dir );
if ( file_exists( $avatar_folder_dir ) ) {
// Avatar has been upload so zero points
// ZERO Points for Avatar Upload if they already uploaded at least 1
function my_bp_avatar_add_cppoints() {
if( function_exists(‘cp_alterPoints’) && is_user_logged_in() ){
cp_alterPoints(cp_currentUser(), 0 );
cp_log(‘Avatar Uploaded’, cp_currentUser(), 0, BuddyPress);
echo ‘zero points’;
}
}
add_action(‘xprofile_avatar_uploaded’,’my_bp_avatar_add_cppoints’);
} else {
// Add Points Avatar Upload
function my_bp_avatar_add_cppoints() {
if( function_exists(‘cp_alterPoints’) && is_user_logged_in() ){
//cp_alterPoints(cp_currentUser(), get_option(‘bp_avatar_spam_add_cp_bp’) );
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);
echo ‘add points’;
}
}
add_action(‘xprofile_avatar_uploaded’,’my_bp_avatar_add_cppoints’);
}