Skip Navigation

[Resolved] cred font end submission with WPML

This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 19 replies, has 3 voices.

Last updated by Jeffrey 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#591073
QQ图片20171119210455.png
QQ图片20171119205921.png

非常感谢你 Luo, 我我尝试一下替换两个选择字段 destination-state, meals-plan 以下是代码

    /**
  *Duplicate Content on submit of Original to all secondary langs (for translation)
  */
 function quick_duplicate_save_data_action( $post_id, $form_data ){
 
 // Change your CRED Form "ID" accordingly below
   if ($form_data['id']== 51){
            // 使用 WPML API   复制post到其他语言版本
            do_action( 'wpml_admin_make_post_duplicates', $post_id ) ;     
  
            $post_id_en = $post_id; //英文版 post ID
            
            $my_field_en = get_post_meta($post_id_en, 'wpcf-' . 'destination-state', true); //读取英文版的my-field值
            $post_id_cn = apply_filters( 'wpml_object_id', $post_id, 'gust', FALSE, 'zh-hans' ); //中文版post ID
            update_post_meta($post_id_cn, 'wpcf-' . 'destination-state');//写入到中文版的my-field;
			
			    $my_field_en = get_post_meta($post_id_en, 'wpcf-' . 'meals-plan', true); //读取英文版的my-field值
            $post_id_cn = apply_filters( 'wpml_object_id', $post_id, 'gust', FALSE, 'zh-hans' ); //中文版post ID
            update_post_meta($post_id_cn, 'wpcf-' . 'meals-plan');//写入到中文版的my-field
        }      
}   
add_action( 'cred_save_data', 'quick_duplicate_save_data_action', 10, 2 );

结果是 post 后台 还是前台页面 字段值都没有显示出来,下面是截图

第二个问题是: 如果是用户字段, 仅仅是更换这个 'wpcf‘ 还有 if ($form_data['id']== 51 更换form id?

第三个问题是: 如果假设用户在中文界面按照中文提交了表单,那么英文的版本 直接按照上面的代码 $post_id_en 改过来就可以吗? ——————这个问题您不用给我些代码或者什么, 我可以照着改一下,能否帮我看看? 谢谢

实在多谢,我知道这已经不是你们的客户支持范畴内的工作了。或请简单点拨一下, 我可以相应的改过来 然后可能的话帮我检查一下

再次谢谢! :)

#591133

而且此贴的原问题已经解决:
https://toolset.com/forums/topic/cred-font-end-submission-with-wpml/#post-585680
你已经可以使用代码自动复制新文章到其他各种语言版本。
https://toolset.com/forums/topic/cred-font-end-submission-with-wpml/#post-587947

关于字段的复制问题,我也为你提供了示例代码:
https://toolset.com/forums/topic/cred-font-end-submission-with-wpml/page/2/#post-589354
你需要根据你自己的网站具体情况做相应的调整, 如果你还需要帮助, 请为新问题创建新帖。这样可以方便其他用户找到答案,谢谢!

#591366

好的,已开新帖,由衷的非常非常感谢你!

#591404

你说的应该是这个帖子:
https://toolset.com/forums/topic/cred-front-end-submission-form-of-multilingual-sites-with-wpml/
我已经take了该贴,尽快给你答复。

另外你在发起新帖的时候是可以直接指派新帖给我,并且现在你也可以关闭此贴了。谢谢!

#592408

已完满解决,非常感谢 🙂