Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save champsupertramp/1216cded8f850b70f2cd38b98590bb9d to your computer and use it in GitHub Desktop.
Save champsupertramp/1216cded8f850b70f2cd38b98590bb9d to your computer and use it in GitHub Desktop.
Ultimate Member - Assign specific default Profile Photo to a user role
add_filter("um_user_avatar_url_filter",function( $url, $user_id, $data ){
um_fetch_user( $user_id );
$role = um_user("role");
if( strpos( $url ,"gravatar") > -1 || strpos( $url ,"profile_photo") < -1 ){
if( $role == 'subscriber' ){
return "https://via.placeholder.com/150/0000FF/FFFFFF?text=Subscriber";
}else if( $role == 'administrator' ){
return "https://via.placeholder.com/150/FF0000/FFFFFF?text=Administrator";
}else if( $role == 'bbp_spectator' ){
return "https://via.placeholder.com/150/FFFF00/FFFFFF?text=Spectator";
}
}
return $url;
}, 999999, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment