Auto-Delete Long Expired Members

Hi,

I need to implement an expiration period for one of our existing membership. Those expired members will need to be auto-deleted (member account & wordpress account). The reason is because, we do not want to bloat our database with those inactive members. Besides, they can re-register again anytime later with using same email address, if they wish to join us back after being deleted.

Please guide on how to perform the auto-deletion of expired members.

Even manual-deletion solution is highly appreciated.

Thank you.

  • Rupok
    • Support Ninja

    Hi Jonathan,

    I’m afraid, this can’t be done out of the box and might require you to hire a developer to do advanced custom coding for achieving this. Membership will expire when the payment is not paid, but I’m afraid, there is no way to auto delete user account after a certain time of expiration.

    For manually deleting expired users, please go to your “Dashboard > Membership 2 > All Members > Expired (Tab)”. There you can see all your expired members. From there, you can get the list of expired users and can delete them manually.

    If you want, I can move this thread to our Features and Feedback section. More people liking this idea, more chances our developers will work on this and will include this feature in our future releases.

    Have a nice day. Cheers!

    Rupok

  • Michael
    • Design Lord, Child of Thor

    Consider a cronjob added under your theme’s function.php file.

    You could setup a value for the user’s last login time…

    add_action( ‘wp_login’,’prefix_save_user_last_login’, 0, 2 );

    function prefix_save_user_last_login( $login, $user ) {

    update_usermeta( $user->ID, ‘user_last_login’, time() );

    }

    Then setup a CronJob with a SQL Query checking their last login time every so often and remove the ones after a certain time period (matching them against the current time). The issue here is you would also want to avoid deleting your own account id, admins, and mods, etc. Working out a safe database query is probably the hardest part. I honestly don’t wish to give an example of this, in case I’m wrong, but hopefully that might help set you on the right track.

    It would be a lot safer to manually approve of the deletion of accounts, such as what Rupok suggested above. Unless you really need a large number removed regularly?

  • Jonathan
    • Site Builder, Child of Zeus

    Thanks Michael,

    But your answer is not ideal because last login time is not directly related to expired members. If a member is logging in everyday but his trial membership is expired, then it will not be auto-delete according to your proposed CRONJOB. On the other hand, there might be a situation whereby official members might not be logging in for a long time but their membership is not expired as they keep paying.

    Anyway, thanks for your good efforts in understanding and answering my issue.

    Appreciate it much.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.