Hey @lukepnnngtn ,
Do you mind sharing how you are calling the API? There is a sample cloning script here https://gist.github.com/theRealRizeo/c59039193b309a0b9a5c9f4b2409e406 that uses the API
$requestClone = array(
'action' => 'ns_cloner_process_init',
'clone_mode' => 'core',
'source_id' => 1, // Replace with the correct source site ID
'target_name' => $business_name_edited,
'target_title' => $business_name,
'tables_to_clone' => $tables_to_clone,
'post_types_to_clone' => $cpt_to_clone,
'do_copy_posts' => 1,
'do_copy_files' => 0,
'do_copy_users' => 1,
'debug' => 1,
'flush_cache' => 1,
'clone_nonce' => wp_create_nonce( 'ns_cloner' ),
);
error_log('requestClone' . print_r( $requestClone, TRUE ));
// Load NS Cloner
if (!function_exists('ns_cloner')) {
return;
}
// This is required to bootstrap the required plugin classes.
ns_cloner()->init();
foreach ( $request as $key => $value ) {
ns_cloner_request()->set( $key, $value );
}
ns_cloner_request()->set_up_vars();
ns_cloner_request()->save();
// Run init to begin.
ns_cloner()->process_manager->init();
}
also have used this
$requestClone = array(
'action' => 'ns_cloner_process_init',
'clone_mode' => 'core',
'source_id' => 1, // Replace with the correct source site ID
'target_name' => $business_name_edited,
'target_title' => $business_name,
'tables_to_clone' => $tables_to_clone,
'post_types_to_clone' => $cpt_to_clone,
'do_copy_posts' => 1,
'do_copy_files' => 0,
'do_copy_users' => 1,
'debug' => 1,
'flush_cache' => 1,
'clone_nonce' => wp_create_nonce( 'ns_cloner' ),
);
error_log('requestClone' . print_r( $requestClone, TRUE ));
// Load NS Cloner
if (!function_exists('ns_cloner')) {
return;
}
ns_cloner()->init();
// Schedule the cloning operation
ns_cloner()->schedule->add(
$requestClone,
time(), // timestamp of date/time to start cloning - use time() to run immediately
'Your Project Name' // name of your project, required but used only for debugging
);
Hi – I think I might be having the same issue as this. Were you able to resolve your issue?
I’m noticing in the log file that the site gets created, then for some reason create_site gets called again, causing a “Sorry, that site already exists!” error.