How to Trigger Cloning from Custom Code or Another Plugin

/**
 * Set up the cloning request.
 * These are the same fields that get submitted via an AJAX request when cloning via the
 * admin interface, so you can inspect that request to determine other ways to configure
 * the parameters, particularly if you're using NS Cloner Pro and want to use another
 * clone mode (like clone-over or teleport / remote cloning)
 */
 $request = array(
    'clone_mode'   => 'core',
    'source_id'    => 1, // any blog/site id on network
    'target_name'  => 'subdomain-or-subdir',
    'target_title' => 'New Site Title',
    'debug'        => 1
 );

// Load WordPress (ONLY if invoking this from outside WordPress).
// Other plugins and themes do NOT need to do this.
require_once( 'wp-load.php' );

// This is required to bootstrap the required plugin classes.
ns_cloner()->init();

// This will create a background process via WP Cron to run the cloning operation.
ns_cloner()->schedule->add(
   $request,
   time(), // timestamp of date/time to start cloning - use time() to run immediately
   'Your Plugin Name' // name of your project, required but used only for debugging
);<br>

Still need help? Contact Us Contact Us