Support

Account

Forum Replies Created

  • I got it!!!
    simply add this line at the beginning of _acf_get_field_by_id function in api-field.php

    remove_all_filters('the_posts');

    All the instructions are now perfectly translated in front-end!

  • The first print_r() results I posted is after the attempt to translate.
    if I edit the post in the admin and save it and then load that post in the front end it is still not working.
    It start to work only after form submission.
    I discover that the problem is in api-filed.php in function _acf_get_field_by_id (starts around line 916).

    First time the page with the form is loaded

    // get post
    	$post = get_post( $post_id );

    return translated values instead of full string values in this way:

    WP_Post Object
    (
        [ID] => 655
        [post_author] => 1
        [post_date] => 2015-06-17 12:25:15
        [post_date_gmt] => 2015-06-17 10:25:15
        [post_content] => a:12:{s:4:"type";s:4:"text";s:12:"instructions";s:99:"(nome e numero della strada)";s:8:"required";i:1;s:17:"conditional_logic";i:0;s:7:"wrapper";a:3:{s:5:"width";i:50;s:5:"class";s:0:"";s:2:"id";s:0:"";}s:13:"default_value";s:3:"azz";s:11:"placeholder";s:0:"";s:7:"prepend";s:0:"";s:6:"append";s:0:"";s:9:"maxlength";s:0:"";s:8:"readonly";i:0;s:8:"disabled";i:0;}
        [post_title] => indirizzo
        ........
    )

    instead of the correct way which is this one:

    WP_Post Object
    (
        [ID] => 655
        [post_author] => 1
        [post_date] => 2015-06-17 12:25:15
        [post_date_gmt] => 2015-06-17 10:25:15
        [post_content] => a:12:{s:4:"type";s:4:"text";s:12:"instructions";s:99:"[:it](nome e numero della strada)[:en](name and number of street)[:fr](nom et numéro de la rue)[:]";s:8:"required";i:1;s:17:"conditional_logic";i:0;s:7:"wrapper";a:3:{s:5:"width";i:50;s:5:"class";s:0:"";s:2:"id";s:0:"";}s:13:"default_value";s:3:"azz";s:11:"placeholder";s:0:"";s:7:"prepend";s:0:"";s:6:"append";s:0:"";s:9:"maxlength";s:0:"";s:8:"readonly";i:0;s:8:"disabled";i:0;}
        [post_title] => [:it]indirizzo[:en]address[:fr]adresse[:]
        ........
    )

    and which is the way $post object is correctly returned after form submission

    In that way inside the _acf_get_field_by_id function

    // unserialize
    	$data = maybe_unserialize( $post->post_content );

    returns a boolean instead of an array due unserialization which gets error while parsing the uncorrect
    s:99:"(nome e numero della strada)";

    of course: the string length is 28 chars and not 99!

  • Hi,
    If I write instructions without qtranslate tags (a simple normal text in one language) on front end it looks perfect.
    The string which I’ve insert doesn’t have extra or converted chars.
    so writing:
    (name and number of street)
    works as expected.
    instead writing:
    [:it](nome e numero della strada)[:en](name and number of street)[:fr](nom et numéro de la rue)[:]
    won’t works.
    I think is breaking something inside field rendering because I get this result when I do a print_r of the field:

    Array
    (
        [ID] => 484
        [key] => field_556d8c8ddc6bc
        [label] => indirizzo
        [name] => indirizzo
        [prefix] => 
        [type] => text
        [value] => 
        [menu_order] => 5
        [instructions] => 
        [required] => 0
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => 469
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => indirizzo
        [_input] => 
        [_valid] => 1
        [default_value] => 
        [maxlength] => 
        [placeholder] => 
        [prepend] => 
        [append] => 
        [readonly] => 0
        [disabled] => 0
    )
    

    but $field['instructions'] is not empty! It’s filled with:
    [:it](nome e numero della strada)[:en](name and number of street)[:fr](nom et numéro de la rue)[:] and also $field['wrapper'] settings are lost

    The really strange behavior is that:
    if form is submitted (so after a POST request) it works as expected.

    Array
    (
        [ID] => 484
        [key] => field_556d8c8ddc6bc
        [label] => indirizzo
        [name] => indirizzo
        [prefix] => 
        [type] => text
        [value] => 
        [menu_order] => 5
        [instructions] => (nome e numero della strada)
        [required] => 1
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => 469
        [wrapper] => Array
            (
                [width] => 50
                [class] => 
                [id] => 
            )
    
        [_name] => indirizzo
        [_input] => 
        [_valid] => 1
        [default_value] => 
        [placeholder] => 
        [prepend] => 
        [append] => 
        [maxlength] => 
        [readonly] => 0
        [disabled] => 0
    )
Viewing 3 posts - 1 through 3 (of 3 total)