BuddyDev

Search

Coding question : wp_delete_user()

  • Participant
    Level: Enlightened
    Posts: 35
    Michael on #55860

    Hi Brajesh,

    Hope you can help. I have written a function to delete “abandoned” accounts from my site, say after x number of days of inactivity.

    Simply loops through the entire member list, and uses the wp_delete_user() function to safely & cleanly remove the account if appropriate.

    Question : is the wp_delete_user() function very slow? Because it seems so, for example if I want it to delete 300 accounts one after the other, it can take 30 seconds to complete. Is this slow, or is it expected?

    Thanks!

  • Keymaster
    (BuddyDev Team)
    Posts: 25203
    Brajesh Singh on #55861

    Hi Michael,
    Welcome back.

    the function is not slow in itself. It runs some hooks(delete_user/deleted_user) which are used by many plugins to cleanup their own content. If you have plugins with large amount of data needing cleanup for the user being deleted, It will cause slowness.

    I will suggest running via cron and chunking to ensure it works without any issue.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved