Create your own WordPress Demo Site

We created our own WordPress demo site with the help of this Cozmos Lab article We edited the code a little bit by increasing the amount of time we needed to create a website, opening up the customizer and adding a message telling the user that we are creating their web site and a link taking users back to their web site when they close the customizer. Recently the code that was used to create new users stopped working. Here is the code that works:

if (! is_user_logged_in() )
$creds = array(
'user_login' => $username,
'user_password' => 'demo',
'remember' => false

$user = wp_signon( $creds, false );

if ( is_wp_error( $user ) ) {
error_log( $user->get_error_message() );


We also used the following plugins:

We only have one theme, but we do have a few plugins and we want you to be able to see what they look like on other themes. The MDCE Theme switcher allows you to switch themes

This plugin is not enabled for multi-site, so we have disabled it.

The Menus plugin allows you to control which menu items are available to demo sites by checking them. The other options are only available to administrator.
















We enabled Multi-Site cloner is installed on the network. We use this plugin and clone our demo sites from a default site that is used.















We redirected users to their own blogs if they tried to get into the admin panel with the help from We had to edit this code a bit to get it to redirect properly. This file goes into the must use plugins director (mu-plugins).


<!--?php /** * The redirect mu-plugin * Redirects user to their primary blog admin once they log in (instead of main site dashboard) * Redirects user to their primary blog admin when they try to access wp-admin of some other blog */ class itg_wpms_login_redirect { /** * Constructor * Hooks the actions */ public function __construct() { add_action('login_redirect', array(&amp;$this, 'login_redirect'), 100, 3); add_action('admin_menu', array(&amp;$this, 'admin_redirect')); } /** * Redirect the users on login * Users should be redirected to their primary site whenever they try to login from anywhere * * Should be hooked * * @param string $redirect_to * @param string $requested_redirect_to * @param string $user * @return string */ public function login_redirect($redirect_to, $requested_redirect_to, $user) { if (is_user_logged_in()) { $user = wp_get_current_user(); if ($user-&gt;ID != 0 &amp;&amp; $user-&gt;ID != 1 &amp;&amp; stristr($user-&gt;user_login, 'demo') !== FALSE) {&lt;br ?--> $primary = get_user_meta($user-&gt;ID , 'primary_blog');
if ($primary) {
$primary_url = get_blogaddress_by_id($primary) . 'wp-admin/';
$redirect_to = $primary_url;
return $redirect_to;

* Redirect the logged in users to their primary site's admin
* when they try to access the admin of the main site or other site
* Comment out line 61 to block only the main site admin
* @global type $current_user
* @global type $blog_id
* @return type
public function admin_redirect() {
global $current_user, $blog_id;

if ($current_user-&gt;ID == 0 || $current_user-&gt;ID == 1)

//the below line blocks access ONLY to the main site wp-admin
//remove the line to block access to all sites except primary
if ($blog_id !='1') return;
$primary = get_user_meta($user-&gt;ID , 'primary_blog');
$primary_url = get_blogaddress_by_id($primary) . 'wp-admin/';

if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') &amp;&amp; ( $blog_id != $current_user-&gt;primary_blog)) {

$itg_wpms_login_redirect = new itg_wpms_login_redirect();