Viewing 1 replies (of 1 total)
  • I fired in the following snippet to functions.php and it works.

    function display_avatar($avatar, $params) {
        $avatar = bp_get_member_profile_data(array('field' => 'IMAGEFIELD', 'user_id' => $params['item_id']));
        return $avatar;
    }
    add_filter('bp_core_fetch_avatar_url', 'display_avatar', 15, 2);
    
    function display_avatar_html($avatar_html, $params) {
        $upload_dir = wp_upload_dir();
        $new_avatar = $upload_dir['baseurl'] . bp_get_member_profile_data(array('field' => 'IMAGEFIELD', 'user_id' => $params['item_id']));
        $parts = explode('"', $avatar_html);
        for ($i=0; $i<count($parts);$i++) {
            if (strpos($parts[$i], 'src=')) {
                break;
            }
        }
        $i++;
        $prev_avatar = $parts[$i];
        return str_replace($prev_avatar, $new_avatar, $avatar_html);
    }
    add_filter('bp_core_fetch_avatar', 'display_avatar_html', 15, 2);

    Only problem is that it doesn’t let you crop images. And some images may be larger than others. It all depends on what the user uploads.

    Is there any way to add cropping this way?

Viewing 1 replies (of 1 total)
  • The topic ‘user image as avatar sync’ is closed to new replies.