Support

Account

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

Solved

Can you force a source language in a front-end form ?

  • I have WPML + an ACF front-end form.

    The field groups are not translated.
    The (custom) post type ‘appears’ as translated.
    The front-end form is shown on a translated page.

    If someone now submits a post, on a Dutch page, the post becomes Dutch but I don’t want that.

    Can I force an input language on the form (without losing all my translations) ?

  • 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 );
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.