Created
February 18, 2020 12:31
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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