Filters and Actions Documentation

The NS Cloner is built to be extended – it includes a lot of custom filters and actions so that it can easily be customized or added on to. Here is a non-exhaustive of some of the most commonly used hooks, which we’ll be documenting further over time:


Filter the available sites in the source and target site lists: ns_cloner_sites_list

add_filter( 'ns_cloner_sites_list', function( $sites ){
   // Replace list of all sites with custom manual selection - useful for very large networks.
   $sites = get_sites( [
      'site__in' => [ 1, 2, 5, 8 ],
   ] );
   return $sites;

Filter the excluded directory list when copying uploads: ns_cloner_dir_copy_ignore

add_filter( 'ns_cloner_dir_copy_ignore', function( $blacklist ){
   $blacklist[] = 'some_plugin_directory_not_to_copy';
   return $blacklist;


Before a site is cloned: ns_cloner_process_init

add_action( 'ns_cloner_process_init', function(){
   // Get array of all submitted cloner options.
   $request = ns_cloner_request()->get_request();
   // Do something here.

After a site is cloned: ns_cloner_process_finish

add_action( 'ns_cloner_process_finish', function(){
   // Get array of all submitted cloner options and calculated variables.
   $request = ns_cloner_request()->get_request();
   // Do something here.