Detecting if User Uploaded an Avatar
-
This seemed to be a simple task, but I’ve been struggling to get it working.
I wish to check on user login if they have uploaded an avatar or if they are using the auto-generated gravatar. For now, I am just trying to get it to redirect to the upload page (I’ll likely pop up a light box, display a notice, or restrict functions in the future).
I have done some searching, and after some tweaking, this is what I have come up with:
function uaol_get_user_has_avatar() { global $bp; $avatar = bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'no_grav' => true, 'html'=>false) ); $pos = strpos($avatar, 'wavatar'); if ($pos === false) { return true;} else { return false; } } function buddypress_redirect_if_no_avatar($redirect_url,$request_url,$user) { $redirect_url = bp_core_get_user_domain($user->ID)."/profile/change-avatar/"; return $redirect_url; } if( !uaol_get_user_has_avatar()){ add_filter("login_redirect","buddypress_redirect_if_no_avatar",100,3); }
This however does not redirect anyone. Can someone point me in the right direction?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Detecting if User Uploaded an Avatar’ is closed to new replies.