• So when my users update their photo with a different file extension than their previous, I get two files in /wp-content/uploads/userphoto with the two different extensions. If they delete the image first, then update it everything is fine.

    So, I’m trying to get the plug-in to delete the previous file and write a new one, rather than update the meta data.

    Having a hell of a time getting this to work. Any help would be appreciated. Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter Tuxxyy

    (@tuxxyy)

    Got it:

    I threw this in around line 416 (after if !error)

    #delete before update
    if($userdata->userphoto_image_file){
    $upload_dir = wp_upload_dir();
    $bdir = trailingslashit($upload_dir[‘basedir’]) . ‘userphoto/’;
    $imagepath = $bdir . basename($userdata->userphoto_image_file);
    $thumbpath = $bdir . basename($userdata->userphoto_thumb_file);

    if(file_exists($imagepath) && !@unlink($imagepath)){
    update_usermeta($userID, ‘userphoto_error’, __(“Unable to delete photo.”, ‘user-photo’));
    }
    else {
    @unlink($thumbpath);
    delete_usermeta($userID, “userphoto_approvalstatus”);
    delete_usermeta($userID, “userphoto_image_file”);
    delete_usermeta($userID, “userphoto_image_width”);
    delete_usermeta($userID, “userphoto_image_height”);
    delete_usermeta($userID, “userphoto_thumb_file”);
    delete_usermeta($userID, “userphoto_thumb_width”);
    delete_usermeta($userID, “userphoto_thumb_height”);
    }
    }

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: User Photo] Updating photo with different file extension’ is closed to new replies.