Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a website to demo plugins, and I want to allow users to login, but I am not sure how to reset the website once they log out. Is there a way to create a separate instance of Wordpress for each new user and then delete itself once that user logs out? Or is there a way to reset a Wordpress site once a day (not reset database and completely reset site), but keep the plugin activated and setup?

share|improve this question
    
I'm searching for the same and found this tutorial. Although haven't tested yet. –  brasofilo Oct 13 '13 at 15:58

1 Answer 1

One way to solve this would be to set up your demo site exactly how you want it to reset every day (use a standard username and pass like "admin" and "testpass"), and then dump the database and zip the files. Then, put the zip somewhere on your server. Set up a BASH script that deletes the contents of the current Wordpress directory, drops all the tables from the database, copies the zip file in, unzips it, and then imports the database file to the db. Then, you can set up a cron to run the file every night at midnight. Here's some info on how to set up a cron:

http://www.cyberciti.biz/faq/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses/

Give me a bit and I'll whip up a code example.

EDIT:

Once you have your files zipped, you can write a BASH script like this:

#!/bin/bash

rm -rf ~/path/to/your-website/*
mysql -u your-db-username -pyour-db-password -e "DROP DATABASE wordpress_database"
cp ~/path/to/your.zip ~/path/to/your-website
unzip ~/path/to/your-website/your.zip
mysql -u your-db-username -pyour-db-password -e "CREATE DATABASE wordpress_database"
mysql -u your-db-username -pyour-db-password wordpress_database < ~/path/to/your-website/db-dump.sql

Something like that should get the job done. Just put this into a file like "reset-test-site.sh", and set up a cron to run the script every night at midnight.

Also, note the lack of a space in the mysql command between the "-p" option and the actual password. This is NOT a typo, and is the way this command works. Just wanted to make sure you know this isn't an error.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.