Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] Any way to automatically delete accounts that have status “activation needed”?

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.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • March 29, 2025 at 7:24 pm #30104
    saschapi
    Participant

    I 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 #30109
    The Assurer
    Moderator

    There is an “Advanced Setting” called Auto Delete Pending Account.

    May 14, 2025 at 11:57 am #30399
    saschapi
    Participant

    As 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 #30403
    admin
    Keymaster

    Thank 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 Operation menu, then scroll down to the section titled Bulk Delete Member Accounts By Status. From there, select Activation Required as 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 #30442
    LaFamilleClub
    Participant

    So, 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 #30443
    The Assurer
    Moderator

    100 rows. But you should try the suggestion by @admin first, if you are not a PHP programmer.

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy