Skip Navigation

Resolved

Reported for: Advanced Custom Fields Multilingual 1.9.1

Resolved in: ACFML 1.9.3

Overview of the issue

Advanced Custom Fields plugin allows you to display forms to add or edit posts. You can even customize it in order to create a specific post using code like this:

1
2
3
4
5
6
7
8
9
10
11
$id = 12;
acf_form(array(
    'post_id'   => 'new_post',
    'post_title'    => true,
    'field_groups'  => array( $id ) ,
    'new_post'      => array(
        'post_type'     => 'post',
        'post_status'   => 'publish'
    ),         
    'submit_value'  => 'add post'
));

However, you cannot use this form to submit content in secondary languages.

Workaround

In order to make this form work in secondary languages, you will need to slightly adapt your code and use our wpml_object_id filter:

1
2
3
4
5
6
7
8
9
10
11
12
$id = 12;
$transid = apply_filters( 'wpml_object_id', $id , 'acf-field-group' );
acf_form(array(
    'post_id'   => 'new_post',
    'post_title'    => true,
    'field_groups'  => array( $transid ) ,
    'new_post'      => array(
        'post_type'     => 'post',
        'post_status'   => 'publish'
    ),         
    'submit_value'  => 'add post'
));

The wpml_object_id filter gets the Field group ID and translates it for each language. Then, the form is able to submit your content successfully.