Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickihastings/b0ba0a8523d79461a7262d4611340069 to your computer and use it in GitHub Desktop.
Save nickihastings/b0ba0a8523d79461a7262d4611340069 to your computer and use it in GitHub Desktop.
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