Support

Account

Home Forums ACF PRO Can you force a source language in a front-end form ? Reply To: Can you force a source language in a front-end form ?

  • Not needed anymore, fixed with a WPML filter.

    function sd_change_language( $post_id ) {
    
        if ( 'post_type' == get_post_type( $post_id ) ) {
            $wpml_element_type           = apply_filters( 'wpml_element_type', 'post_type' );
            $get_language_args           = array( 'element_id' => $post_id, 'element_type' => 'post_type' );
            $original_post_language_info = apply_filters( 'wpml_element_language_details', null, $get_language_args );
            $set_language_args           = array(
                'element_id'           => $post_id,
                'element_type'         => $wpml_element_type,
                'trid'                 => $original_post_language_info->trid,
                'language_code'        => 'en', // language code to change it to
                'source_language_code' => null
            );
    
            do_action( 'wpml_set_element_language_details', $set_language_args );
        }
    }
    add_action( 'acf/save_post', 'sd_change_language', 1, 1 );