Duplicate Site for WordPress Multisite: Hook Reference

rudr_pre_duplicate_blog

This filter allows not only to run some code before a specific blog has been duplicated but also to prevent it from being duplicated.

$check = apply_filters( 'rudr_pre_duplicate_blog', null, $blog );
$checkmixed
When the value of the filter is equal to anything except null, the blog won’t be cloned.
$blogWP_Site
An object of a target blog which is about to be duplicated.

Example. Prevent a specific blog from being cloned and run custom code instead

add_filter( 'rudr_pre_duplicate_blog', function( $check, $blog ) {
	
	if( 5 === $blog->blog_id ) {
		
		// we can run some custom code here
		
		// prevent it from being duplicated
		$check = false; // any value except null

	}

	return $check;
	
}, 25, 2 );

It is also possible to check other properties of the WP_Site object, for example, $blog->domain, $blog->path, $blog->registered, $blog->public, etc.

rudr_duplicated_blog

This action hook is fired when a blog has been duplicated, at the end.

do_action( 'rudr_duplicated_blog', $blog_id, $new_blog_id );
$blog_idint
The ID of a blog which is being duplicated at this moment.
$new_blog_idint
The ID of a blog copy.