availability:

WPML Version: 3.2

description:

Builds duplicate posts from a “master” post. This action hook is reserved for front-end calls.

type:
action
category:
Inserting Content
parameters:
do_action( 'wpml_make_post_duplicates', int $master_post_id )
$master_post_id
(int) (Required) The ID of the post to duplicate from. It can be that of a post, page or custom post. The “master post” doesn’t need to be in the default language
hook example usage:

In the example below, we create duplicates for a post when we insert it from the front-end.
Our function will fire when the footer is loaded on the front-end.

Example

add_action('wp_footer', 'my_duplicate_on_insert');
function my_duplicate_on_insert() {
	// Create post object
	$my_post = array(
	  'post_title'    => 'My post to insert from the front-end',
	  'post_content'  => 'This is my post.',
	  'post_status'   => 'publish',
	  'post_author'   => 1,
	  'post_category' => array(1)
	);

	// Insert the post into the database
	$post_id = wp_insert_post( $my_post );
	if ( $post_id ) {
		do_action( 'wpml_make_post_duplicates', $post_id );
	}
}