• Hi,

    I am using the spam/ham feature from BuddyPress and it seems that the image file a user upload with your plugin is not deleted when his account is set to spam, which erase his whole xprofile data.

    When removing the user spam status, his xprofile informations are virgin. Your plugin offers to upload an image but the previous file is still present on the server, and uploading a new image is not removing the previous one neither.

    Is there a deleting image function with your plugin I could call with the spam action hook ?

    Thanks,

    GB

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author BuddyDev

    (@buddydev)

    Hi GB,
    We do cleanup on the field delete.

    We use the hook ‘xprofile_data_before_delete’ to delete files.

    If you use the function “xprofile_delete_field_data()” to delete field data, The above hook will be called automatically.

    Regards
    B

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    Thank you for your answer. Actually this spam feature is a core BP function, I don’t control which function is BP using to delete the fields.

    If you take a look to this file :
    /wp-content/plugins/buddypress/bp-xprofile/bp-xprofile-functions.php

    The code below is the function used to delete the xprofile data in some special cases :

    /** 
     * When a user is deleted, we need to clean up the database and remove all the 
     * profile data from each table. Also we need to clean anything up in the 
     * usermeta table that this component uses. 
     * 
     * @since 1.0.0 
     * 
     * @param int $user_id The ID of the deleted user. 
     */ 
    function xprofile_remove_data( $user_id ) { 
      BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 
    } 
    add_action( 'wpmu_delete_user', 'xprofile_remove_data' ); 
    add_action( 'delete_user', 'xprofile_remove_data' ); 
    add_action( 'bp_make_spam_user', 'xprofile_remove_data' ); 

    As you can see, the last line is calling ‘bp_make_spam_user’ hook. And the function it plays got no hook to call to. What do you think about adding an additional cleanup call to bp_make_spam_user hook ?

    GB

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    You can reproduce this issue by using the BP spam link available for each user from the backend users panel.

    Have a nice day,

    GB

    Plugin Author BuddyDev

    (@buddydev)

    Hi GB,
    Thank you for your patience with us.

    We are adding the support for spam hook in our next update(It will be available this week).

    Regards
    B

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    Many thanks for the fix.

    Have a nice day,

    GB

    Plugin Author BuddyDev

    (@buddydev)

    Hi GB,
    Hope you are doing well.
    It has been fixed in 1.1.6 and should work as expected.

    Regards
    B

    Thread Starter gingerbooch

    (@gingerbooch)

    Thank you @buddydev !! ??

    GB

    Plugin Author BuddyDev

    (@buddydev)

    Thank you. We sincerely appreciate your patience and support ??

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    I finally tested your last upate but I can’t get the problem fixed this way.
    Please, see below.

    ** Testing spam **
    After the last update, I created a new testing user on a test server.
    I uploaded an image file to his profile (xprofile … with your plugin)
    I see the file on the server.
    Then I mark the user as spammer from WordPress users’ dashboard.
    Then the file is still on the server.
    I unspam the user and upload a new image file on his xprofile.
    A second image file appears in the upload folder corresponding to this user ID.
    I delete the user : the images files and folders corresponding to this user are still present on the server.

    ** Testing delete **
    I create a new user, and add an image to his xprofile with your plugin.
    I delete the user : the image file and the folders corresponding to this user are still present on the server.

    Can you check this please ?

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    Did you see my last answer ?
    I’m still having the same issue after updating to 1.1.6 .

    GB

    Plugin Author BuddyDev

    (@buddydev)

    Hi GB,
    I am sorry, I missed your notification in my mail.

    I will test and update you in next 2 days.

    Thank you
    Brajesh

    Plugin Author BuddyDev

    (@buddydev)

    Hi,
    Hope you are doing well.
    You were right, the issue was not resolved. It is now. Please upgrade to 1.1.7 and try it.

    Regards
    Brajesh

    Thread Starter gingerbooch

    (@gingerbooch)

    Hi @buddydev,

    Thank you for taking the time to work on it.

    Now the uploaded picture is well deleted when a user is marked as a spammer or when a user is deleted.

    I notice that the user‘s folders (the one with user ID + the sublevel folder “image”) are not deleted.

    Is it possible to delete those folders too please ? Maybe not for spammers but when the user is deleted, the folders have no more reason to stay in.

    GB

    Thread Starter gingerbooch

    (@gingerbooch)

    Maybe something like this ?

    WP_Filesystem();
    $wp_filesystem->rmdir($path_2_folder, true); // true for recursive
    Plugin Author BuddyDev

    (@buddydev)

    Hi GB,
    Thank you for the suggestion.

    We can not use above code unless we make sure to verify that the folder is empty. The plugin media removal script is not aware whether it is profile delete/spam or just filed value update.

    I will be adding the code to check for empty directory and remove it in our next update.

    Thank you
    Brajesh

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Image files don’t delete with xprofile erase’ is closed to new replies.