Create your own Demo Site

We created our own 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.

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

The Menus plugin allows you to control which menu items are available to demo sites by setting specific items to administrator use only.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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 Intechegrity.com. 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).

itg_wpms_login_redirect.php


<?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(&$this, 'login_redirect'), 100, 3);
        add_action('admin_menu', array(&$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->ID != 0 && $user->ID != 1 && stristr($user->user_login, 'demo') !== FALSE) {
            $primary = get_user_meta($user->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->ID == 0 || $current_user->ID == 1)
            return;

        //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->ID , 'primary_blog');
        $primary_url = get_blogaddress_by_id($primary) . 'wp-admin/';

        if (strpos($_SERVER['REQUEST_URI'], 'wp-admin') && ( $blog_id != $current_user->primary_blog)) {
            wp_redirect($primary_url);
        }
    }
}

$itg_wpms_login_redirect = new itg_wpms_login_redirect();