Auto Reset

I’ve been wanting to set up a ‘Test Drive WordPress’ site, and I think I’ve finally got the script that will get me there.

I tried to make it easy to configure, so you’ll find all the basic options at the top of the file. Of course, if you want more advanced customization (multiple users, extra posts, active plugins) you’ll need to add that yourself.

The idea here is that when the code first runs, it’ll schedule and update for one hour (or whatever you specify) from now. From then on, it will always compare the current time to the next scheduled time, and reset if it’s time to do so.

Why not use the built-in WP Cron API? I tried. Maybe I’m doing something wrong, but I just couldn’t get it to work for me.

During the reset, this is what happens:

  1. All files in the upload directory are deleted
  2. All WP database tables are dropped
  3. WP is reinstalled with given settings. Default settings defined in this plugin:
    • Blog title: WP Testdrive
    • User name: demo
    • User email: [email protected]
    • Public: 0
    • User password: demo

Other options:

  • Hide welcome dashboard (default, true): Hides the large welcome panel that appear on the dashboard of a new installation
  • Show feature pointers (default, false): Make the feature pointers appear, though they would normally be hidden on new installations
  • Show credentials on login page (default, true)
  • When someone logs in as the demo user, create a new demo user, show new credentials on login screen (default, true)
  • Generate random passwords for new demo users (default, true)

[zip id=1255]

Notes

Use with caution. This has had only limited testing so far, and none of it on multisite. This thing is dropping tables, so make sure there are none you want to keep. That said, be smart, and if something goes wrong, don’t blame me (seriously, you’ve been warned).

You’ll also want to make this a must-use plugin (put it in wp-content/mu-plugins) so that it can’t be deactivated by your test drivers.

Also, if copying the code directly from this post, it may be unescaping a few quote marks in the javascript.

Bugs or Suggestions?

Let me know in the comments, or catch me on twitter (@trepmal).

Updates

December 16: fixed silly bug where I used the wrong variable names for ‘hide welcome dashboard’ and ‘show feature pointers’.

December 16 (2): added more options. Next reset time is saved in an array so that it cannot be changed via options.php

December 17: Reset will only happen on admin-side. Fixed issues if ?resetnow is run on wp-login.php. Fixed redirect after reset.

2 thoughts on “Auto Reset”

  1. corradomatt

    This looks like an interesting plugin. Is it still supported? I’m interested in using it to give users a test-drive of my custom theme options. Could I setup the plugin to use my custom sql file for the database reset? I also wouldn’t want it to delete the media files because I wouldn’t be giving the demo users access to upload media anyway. I’d basically lock down the admin for the demo user for everything accept the theme admin options.

Leave a Reply

Your email address will not be published. Required fields are marked *