Set a subsite expiration, or monitor subsites for non-used sites to delete

Hi All!

I have a Multisite installation with around 3000 subsites, for my WP Dev Udemy course Student Sandbox. It's a private network for students fo the course.

I'd like to be able to delete older, unused subsites.

Can I use Prosites or another solution to set a non-use expiration, or a time-limit after which subsites are deleted?

Or alternatively, can I monitor when subsites have had no activity fro thre months, and then delete them manually?

Thanks for your ideas!

Gregg Davis

  • Mr. Dick
    • Flash Drive

    Just to clarify, when you mean no activity, do you mean nobody access the CONTENT on the site or do you mean no UPDATES / LOGINS?

    I was just having a look at the users_meta table and noticed an entry
    itsec_user_activity_last_seen which seems to be created by iThemes Security (not sure if you are using that) - but it matches the date of last login. Maybe link that back if each sub-site only has one user? Or use use a MAX function grouped on the site ID to find the date of last login. Then it would just be a matter of making an update to that's blogs' option table (blog_public) to 0? I'm sure that would work.

    Probably not the GUI-based way of doing it you were looking for, but a little MySQL scripting never hurt anyone!

  • Gregg Davis
    • Design Lord, Child of Thor

    Thanks Dick! You're right, I'm not sure I understand enough to do it the way you're stating, but I just did find that I can manually see all sites in the network and sort by date modified. I could then manually delete sites from the SuperAdmin dashboard.

    I wonder if a plugin like Pro Sites already had this functionality.


  • Adam Czajczyk
    • Support Gorilla

    Hello Gregg,

    I hope you're well today and thank you for your question!

    The Pro Sites plugin could be used to "deactivate" sites after certain time but that's based on "subscription period" rather than activity. You would need to create a Pro Site level, then manually assign it to the site (as the timeframe can be specified then) and such site would be deactivated after given time if no update (meaning payment for subscription) would be made by its "owner" (sub-site admin). I don't think though that would be a solution for you then.

    I think what Mr. Dick suggested above would be closer to your ideal solution but still, that would also require iThemes security installed and would involve some custom coding.

    There is a plugin that might be helpful though. It's not popular and has not been updated for quite a long time but it might still be working so it's worth giving a try (though I would suggest trying it on a staging/dev site):

    I believe it could probably be also modified to delete such sites instead of just "unpublishing" them.

    The "ultimate" solution though would have to be custom coded in my opinion. Such script should fetch current date/time (preferably unix timestamp using php time() function) and save it to the database as a site_meta value upon each site load. It would also need to first check referrers/user-agents to filter out web crawlers/bots traffic before saving the data. It would also need to update that date upon user login.

    Thne the second part of the script would run based on WP Cron and periodically check these saved date and if e.g. 3 months have already passed, the site would be removed. That would require custom coding though that's outside the scope of this forum so you might want to as a question on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:

    Best regards,

  • Gregg Davis
    • Design Lord, Child of Thor

    Hi Adam!

    I appreciate your suggestions - especially the Pro Sites idea - I wonder if I would be able to set it up such that the site users would have to "renew" their free user account every three months, and if they don't then their account would be placed on hold. If users could renew their accounts by logging in and checking a box for a $0.00 payment, and Pro Sites could initiate email reminders, then I would have a stream of "canceled" sites.

    From there, I could delete all "non-renewed" sites every six months, manually.

    Does this sound like it could work, with Pro Sites?


  • Adam Czajczyk
    • Support Gorilla

    Hello Gregg!

    I think that could be possible that way. First option would be to use... manual payment gateway. You could set a single Pro Site level and "let it use everything" (plugins, themes), with 3-months payments only. A user would have to "pay" every three months but the payment actually means pushing a button "confirming payment". You then receive an activation code - as a super admin - and can activate the site that way. If you don't do it, site gets blocked.

    You could also try to set $0 payment with PayPal and that should work too. PayPal itself doesn't allow "0" payments but if I'm not mistaken Pro Sites should now include a "tweak" for that to accept such payments. I would however suggest checking it first on some staging site.

    If you have any additional questions, let me know please.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.