Hi, I have encountered another issue in addition to the previous ticket I opened. I have already created the user for the sections I want (I don't know how to remove wpml and profile, but it's not a big deal).
The problem I have is that in Events (the first taxonomy, the other events that appear below will be deleted), it won't let me duplicate an event that I want to use as a template, and I can't see where to give access in the Access options.
I think the problem comes from the fact that we have the Duplicator plugin, and the clone button may come from there.
If you can help me, I would appreciate it.
Minesh
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello. Thank you for contacting the Toolset support.
The duplicate post plugin should be from Yoast. You can use the "dp_duplicate_post" hook from the "Yoast Duplicate Post" plugin:
=> hidden link
If you want to duplicate repeating field group items when you duplicate the post:
function my_custom_dp_duplicate_post( $new_post_id, $post ) {
$parent_post = 'book';
$rfg_post = 'book-rfg';
if ( get_post_type( $new_post_id ) == $parent_post ) {
$rfg_ids = toolset_get_related_posts($post->ID, $rfg_post,'parent',999,0,array(),'post_id','child');
if(count($rfg_ids) > 0 ) {
foreach($rfg_ids as $k=>$v):
// Copy post metadata
$data = get_post_custom($v);
$my_post = array(
'post_title' => get_the_title($v),
'post_content' => '',
'post_status' => 'publish',
'post_author' => $post->post_author,
'post_type' => $rfg_post
);
// Insert the post into the database
$insert_post_id = wp_insert_post( $my_post );
// connecting RFG item to newly cloned $post_id
toolset_connect_posts($rfg_post, $new_post_id, $insert_post_id );
foreach ( $data as $key => $values) {
foreach ($values as $value) {
add_post_meta( $insert_post_id, $key, $value );
}
}
endforeach;
}
}
}
add_action( 'dp_duplicate_post', 'my_custom_dp_duplicate_post', 50, 2 );
+
Please change "book" and "book-rfg" with your parent and child/repeating field group post type slugs, respectively.
Note: The custom code examples from our forum are shared to get you started in the right direction.
I hope you can use above example and that will help you to start and explore.
Here are few related tickets that may help you:
- https://toolset.com/forums/topic/duplicate-post-with-relationships/#post-1850911
- https://toolset.com/forums/topic/im-unable-to-duplicate-post-with-its-repeating-field-content-2/#post-1817785
- https://toolset.com/de/forums/topic/wpml-language-duplicate-not-being-created-correctly-100-of-the-time/?paged=2#post-2677721