Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Duplicate a post created with Formidable Forms frontend post submission, so that it is available in all languages. Needs WPML.
<?php
add_action('frm_after_create_entry', 'add_translation', 30, 2);
function add_translation($entry_id, $form_id) {
$forms = array( 64 ); // <---- change or add form ids here, comma separated, e.g. (24, 53, 64)
// check if form id is in array, if so run code
if( in_array($form_id, $forms) ) {
// 1. get the post_id of the CTP post just created
$post_id = FrmDb::get_var( 'frm_items', array( 'id' => $entry_id ), 'post_id' );
// 2. Make a duplicate of the post in all languages
global $sitepress;
do_action( 'wpml_make_post_duplicates', $post_id);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.