Simple Membership Plugin › Forums › Simple Membership Plugin › Any way to automatically delete accounts that have status “activation needed”?
- This topic has 5 replies, 4 voices, and was last updated 1 year, 2 months ago by
The Assurer.
-
AuthorPosts
-
March 29, 2025 at 7:24 pm #30104
saschapi
ParticipantI would like to automatically remove accounts (inlcuding the WP user) of people that did not click their actication link after 24 hours. Is there any way to do that by wordpress cron or a hook? Doing the bulk delete all the time is pretty annoying.
Thank you for your input
March 30, 2025 at 12:03 am #30109The Assurer
ModeratorThere is an “Advanced Setting” called Auto Delete Pending Account.
May 14, 2025 at 11:57 am #30399saschapi
ParticipantAs others mentioned before, this setting will not delete accounts that did not manually validated their email. In case that others are looking for a way to auto delete accounts that registered and did not manually validated their email after a certain period of time, this function added to the functions.php or a custom plugin might help:
// Delete not activated members after three days add_action('swpm_delete_pending_account_event', 'delete_not_activated_accounts'); function delete_not_activated_accounts() { global $wpdb; $query = $wpdb->prepare("SELECT member_id,user_name FROM {$wpdb->prefix}swpm_members_tbl WHERE account_state='activation_required' AND subscription_starts < DATE_SUB(NOW(), INTERVAL 3 DAY) LIMIT %d, 100", $counter); $results = $wpdb->get_results($query); if (empty($results)) { //No more records to process. Break out of the loop. return false; } $to_delete = array(); foreach ($results as $result) { //Delete SM member $query = "DELETE FROM {$wpdb->prefix}swpm_members_tbl WHERE member_id ='".$result->member_id."'"; $wpdb->query($query); //Delete WP user $queryWP = "DELETE FROM {$wpdb->prefix}users WHERE user_login = '".$result->user_name."'"; $wpdb->query($queryWP); } }It uses the same hook as the pending account deletion. In this case it deletes those users after 3 days if they did not click the link in their email and activated their account. It is necessary to ALSO delete the WP account which this function does for you.
Hope this helps others. Sascha
May 15, 2025 at 4:35 am #30403admin
KeymasterThank you. Just adding more info to this. We have the following feature for manually bulk deleting accounts by ‘account status’ which might be helpful.
Go to the
Members→Bulk Operationmenu, then scroll down to the section titledBulk Delete Member Accounts By Status. From there, selectActivation Requiredas the account status and click the Delete button. This will remove all accounts currently marked with the “Activation Required” status.May 28, 2025 at 3:20 am #30442LaFamilleClub
ParticipantSo, I’m not a PHP programmer, and this isn’t clear: LIMIT %d, 100
Does this limit it to 100 rows? 100 days? Do I want to limit it?
May 29, 2025 at 2:42 am #30443The Assurer
Moderator100 rows. But you should try the suggestion by @admin first, if you are not a PHP programmer.
-
AuthorPosts
- You must be logged in to reply to this topic.