Support

Account

Forum Replies Created

  • Thank you jessepearson, it works great!

    @ACF Team: any chance a function/action like this can get into the plugin? It is very useful for automatic site deployment, especially in multisite installations.

  • I have the same problem but on flexible layouts fields.

    i would like to make some customized css for different layouts of the same repeater.

    I ended up adding some jquery to get the data-layout attribute from repeater layout row and using it as css class to the very same element.
    So you’ll have different classes for different repeater layouts, based on the layout name.

    this is the small script I’ve done, nothing special but it works.

    jQuery.noConflict()(function($){
        "use strict";
         $(document).ready(function() {
            var layouts = $('.acf-flexible-content .layout');
            layouts.each(function( key, value ) {
    
                    var section_attribute = $(this).attr('data-layout');
    
                    $(this).addClass(section_attribute);
    
            });
    
        });
    });

    Would be surely better if this classes were built in ACF PRO

  • problem Solved here

    acf.screen is an old method, now we must use: acf.ajax.update

  • Thanks to Eliot supporto i solved.
    Correct way to reference to acf js is

    acf.ajax.update( 'cpt', jQuery(this).val() ).fetch();

    I made a github fork of the lukechapman plugin, tu be used for Single Post Template plugin instead of Custom Post Template plugin

    https://github.com/bluantinoo/single-post-template-support-for-acf

  • Quite same issue here,
    I’ve expained here better: support.advancedcustomfields.com/forums/topic/assign-acf-to-a-post-template/#post-34918

    I’m using ACF PRO

    Maybe the object acf.screen does not more exist or has changed name, or it’s different in PRO version?

    Would really like to have an answer on this.

    PS: Is there any documentation about acf.screen stuff?

  • Hi charis,
    I’m trying to use the plugin along with Single Post Template, I made some few steps, but I’ve got a js error.

    This is what I’ve done:

    In the main plugin file:
    https://github.com/lukechapman/custom-post-template-support-for-acf/blob/master/acf-custom-post-template-support.php

    1) I changed all “Template Name Posts” to “Single Post Template” (there are a few)

    2) I changed the jquery selector to match the Single Post Template dropdown id: #post_template (instead of #custom_post_template as in CPT plugin)

    I have post templates in dropdown,
    but when I switch template, I have this js error:

    TypeError: acf.screen is undefined

    PS: I’m using ACF PRO 3.7.4

  • OK, this is far too complicated for the time window I have.

    Maybe is possible to pre-populate fields? Like precheck the field that fires the condition?

  • I tried to use the add_action filter I was already using in the first version, but without the do_actino in the acf/pre_save_post filter.

    It looks like it works, but I’m still using

    add_post_meta( $post_id, '_thumbnail_id', $image );

    instead of yours

    set_post_thumbnail($post, $attachment_id);

    do you suggest to use the second one?

  • John You’re awesome.

    I think the key is putting the ‘acf/pre_save_post’ filter before:

    acf_form_head();
    get_header();

    but I still have 1 issue: featured image is not saving.

    maybe the ‘acf/save_post’ action is needed fo this like I saw in that article I linked before?

  • 1) no other filter, just frontend templates

    2) As you can see I use 2 field groups in the acf_form. The first one is made just for frontend form (is where I have post title, content and featured image), the second one (where I have the issue) is the very same I use in backend.

    3) IN the 2nd field group I have 6 fields, in this order:
    – true/false field (true is the condition for all the following fields to show) – working
    – wysiwyg field – working
    – flexible content field (inside there are 4 layouts, with a total of 11 subfields) – not working
    – flexible content field (inside there are 2 layouts with a total of 5 subfields) – Not working
    – flexible content field (inside there are 2 layouts with a total of 3 subfields) – Not working
    – wysiwyg field – working

    If you want to try, I’ve exported both groups in this zip file https://dl.dropboxusercontent.com/u/3261727/field-groups.zip

    PS: I’ve tried not to use the second group (the complex one) and using another one just with 1 repeater field with only one text subfield, same problem: data is sent from the form, rows are created in backend but values are empty, infact in database I can see serialized strings like this one: a:2:{i:0;s:1:”A”;i:1;s:1:”A”;}

  • I tried like you suggest.

    add_filter('acf/pre_save_post' , 'tsm_do_pre_save_post' );
    function tsm_do_pre_save_post( $post_id ) {
    
    	// Bail if not logged in or not able to post
    	if ( ! ( can_user_post_recipe() ) ) {
    		return $post_id;
    	}
    
    	// check if this is to be a new post
    	if( $post_id != 'new' ) {
    		return $post_id;
    	}
    
    	// Create a new post
    	$post = array(
    		'post_type'     => 'post', 
    		'post_status'   => 'pending', 
    		'post_title'    => wp_strip_all_tags($_POST['acf']['field_559a8e6366915']), // Post Title ACF field key
    		'post_content'  => $_POST['acf']['field_559a8e7b66916'], // Post Content ACF field key
    	);
    
    	$post_id = wp_insert_post( $post );
    	
    	wp_set_object_terms($post_id, array(1829), 'category');
    	
    	// ACF image field key
    	$image = $_POST['acf']['field_559a8eb766918'];
    	
    	// Bail if image field is empty
    	if ( empty($image) ) {
    		return $post_id;
    	}
    
    	// Add the value which is the image ID to the _thumbnail_id meta data for the current post
    	add_post_meta( $post_id, '_thumbnail_id', $image );
    
    	return $post_id;
    	
    }

    Now the wp_set_object_terms seems to work nicely, but the thumbnail is not saved at all, and the original issue is still there: no repeater or flexible field saved in db.

    Maybe I did not say this: in backend everything is working fine (since a lot of time)

    I can’t see any error, not js in console, not php in server log.

  • Actually I tried to follow this article:
    http://thestizmedia.com/front-end-posting-with-acf-pro/

    anyway I keep having the same issue even removing that line.

    Lately I tried also assign to the post a category in the pre_save_post, adding this line
    wp_set_object_terms($post_id, array(1829), ‘category’);

    right after
    add_post_meta( $post_id, ‘_thumbnail_id’, $image );

    but it works randomly, sometimes the category is assigned, sometime not.

    I’ve also moved all the code (except the acf_form part) from page template to theme funcions.php, but nothing’s changed.

    Problem is I need this to work asap, after losing 2 days on this I’m ready to pay someone to fix it. Anyone available?

  • Further update.

    debugging the form data with chrome dev tools, it looks like the values are sent, but for some reason they are not saved in db

    here it is the admin-ajax.php form data sent in headers

    _acfnonce:d1c835265a
    _acfchanged:1
    _acf_form:eyJpZCI6ImZyb250ZW5kLXJlY2lwZSIsInBvc3RfaWQiOiJuZXciLCJuZXdfcG9zdCI6ZmFsc2UsImZpZWxkX2dyb3VwcyI6WyJncm91cF81NTllOWVkYjQwZmNhIiwiZ3JvdXBfNTU5ZTllZGI1Yzg1ZCJdLCJmaWVsZHMiOmZhbHNlLCJwb3N0X3RpdGxlIjpmYWxzZSwicG9zdF9jb250ZW50IjpmYWxzZSwiZm9ybSI6dHJ1ZSwiZm9ybV9hdHRyaWJ1dGVzIjp7ImlkIjoicG9zdCIsImNsYXNzIjoiIGFjZi1mb3JtIiwiYWN0aW9uIjoiIiwibWV0aG9kIjoicG9zdCJ9LCJyZXR1cm4iOiJodHRwOlwvXC93d3cubm9ubmFwYXBlcmluYS5pdFwvaW5zZXJpc2NpLXJpY2V0dGFcLz91cGRhdGVkPXRydWUiLCJodG1sX2JlZm9yZV9maWVsZHMiOiIiLCJodG1sX2FmdGVyX2ZpZWxkcyI6IiIsInN1Ym1pdF92YWx1ZSI6IkludmlhIFJpY2V0dGEiLCJ1cGRhdGVkX21lc3NhZ2UiOiJTYWx2YXRvISIsImxhYmVsX3BsYWNlbWVudCI6InRvcCIsImluc3RydWN0aW9uX3BsYWNlbWVudCI6ImxhYmVsIiwiZmllbGRfZWwiOiJkaXYiLCJ1cGxvYWRlciI6ImJhc2ljIn0=
    acf[field_559a8e6366915]:This is the post title
    acf[field_559a8e7b66916]:this is the post content
    acf[field_559a8eb766918]:C:\fakepath\80_IMG_2650.jpg
    acf[field_5368b65e4cd39]:1
    acf[field_5383505f17035]:this is another wysiwyg field
    acf[field_5368bdb913e74]:
    acf[field_5368bdb913e74][acfcloneindex][acf_fc_layout]:recipe_tot_time
    acf[field_5368bdb913e74][acfcloneindex][field_5368beb2078cc]:
    acf[field_5368bdb913e74][acfcloneindex][field_5368bf64078cd]:
    acf[field_5368bdb913e74][acfcloneindex][field_536cfd2d6fa7a]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfd516fa7b]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfdab6fa7c]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfb9f6fa76]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfbfb6fa77]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfc516fa78]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfeb06fa7f]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfed36fa80]:0
    acf[field_5368bdb913e74][acfcloneindex][field_536cfef46fa81]:0
    acf[field_5368bdb913e74][559fe5a1e1e57][acf_fc_layout]:recipe_dosi
    acf[field_5368bdb913e74][559fe5a1e1e57][field_5368beb2078cc]:5
    acf[field_5368bdb913e74][559fe5a1e1e57][field_5368bf64078cd]:people
    acf[field_5368bdb913e74][559fe5a7e1e58][acf_fc_layout]:recipe_prep_time
    acf[field_5368bdb913e74][559fe5a7e1e58][field_536cfd2d6fa7a]:0
    acf[field_5368bdb913e74][559fe5a7e1e58][field_536cfd516fa7b]:0
    acf[field_5368bdb913e74][559fe5a7e1e58][field_536cfdab6fa7c]:30
    acf[field_5368bdb913e74][559fe5afe1e59][acf_fc_layout]:recipe_cook_time
    acf[field_5368bdb913e74][559fe5afe1e59][field_536cfb9f6fa76]:0
    acf[field_5368bdb913e74][559fe5afe1e59][field_536cfbfb6fa77]:0
    acf[field_5368bdb913e74][559fe5afe1e59][field_536cfc516fa78]:20
    acf[field_5368bdb913e74][559fe5b2e1e5a][acf_fc_layout]:recipe_tot_time
    acf[field_5368bdb913e74][559fe5b2e1e5a][field_536cfeb06fa7f]:0
    acf[field_5368bdb913e74][559fe5b2e1e5a][field_536cfed36fa80]:0
    acf[field_5368bdb913e74][559fe5b2e1e5a][field_536cfef46fa81]:50
    acf[field_53694b8b14a44]:
    acf[field_53694b8b14a44][acfcloneindex][acf_fc_layout]:recipe_ingredient
    acf[field_53694b8b14a44][acfcloneindex][field_5369557ce3365]:
    acf[field_53694b8b14a44][acfcloneindex][field_53694c0014a45]:
    acf[field_53694b8b14a44][acfcloneindex][field_53694c8514a46]:
    acf[field_53694b8b14a44][acfcloneindex][field_53694cdd14a47]:
    acf[field_53694b8b14a44][acfcloneindex][field_53694cf514a48]:
    acf[field_53694b8b14a44][559fe5b7e1e5b][acf_fc_layout]:recipe_ingredient
    acf[field_53694b8b14a44][559fe5b7e1e5b][field_53694c0014a45]:1
    acf[field_53694b8b14a44][559fe5b7e1e5b][field_53694c8514a46]:spoon
    acf[field_53694b8b14a44][559fe5b7e1e5b][field_53694cdd14a47]:sugar
    acf[field_53694b8b14a44][559fe5b7e1e5b][field_53694cf514a48]:
    acf[field_53694b8b14a44][559fe5c1e1e5c][acf_fc_layout]:recipe_ingredient
    acf[field_53694b8b14a44][559fe5c1e1e5c][field_53694c0014a45]:200
    acf[field_53694b8b14a44][559fe5c1e1e5c][field_53694c8514a46]:ml
    acf[field_53694b8b14a44][559fe5c1e1e5c][field_53694cdd14a47]:water
    acf[field_53694b8b14a44][559fe5c1e1e5c][field_53694cf514a48]:
    acf[field_536954f9e3362]:
    acf[field_536954f9e3362][acfcloneindex][acf_fc_layout]:recipe_process_step
    acf[field_536954f9e3362][acfcloneindex][field_53695987027e2]:
    acf[field_536954f9e3362][acfcloneindex][field_5369588b92009]:
    acf[field_536954f9e3362][acfcloneindex][field_536958c19200a]:
    acf[field_536954f9e3362][559fe5d5e1e5d][acf_fc_layout]:recipe_process_step
    acf[field_536954f9e3362][559fe5d5e1e5d][field_5369588b92009]:pur sugar in water
    acf[field_536954f9e3362][559fe5d5e1e5d][field_536958c19200a]:
    acf[field_536954f9e3362][559fe5dce1e5e][acf_fc_layout]:recipe_process_step
    acf[field_536954f9e3362][559fe5dce1e5e][field_5369588b92009]:mix a lot and drink
    acf[field_536954f9e3362][559fe5dce1e5e][field_536958c19200a]:
    acf[field_53695a0dcfde2]:this is yet another wysiwyg field
    action:acf/validate_save_post

    PS: what is “acfcloneindex”?

  • New update:

    I tried using a more simple field group, containing just
    – a repeter field of text fields
    – a flexible content field with 2 fields: text and image

    for both I have the same issue: fields are created in database, infact I see rows in backend edit post, but this rows do not have any value inside. they are just empty.

  • I have an update, looking in db, I can see that the repeater fields are saved, but they are just empty, this is a screenshot: http://prntscr.com/7r2jjm

    In screenshot, the repeater field is “recipe_details”, this field contains severao flexible layout fields, that are not saved, infact the metavalus is just an empty serialized string -> a:2:{i:0;s:1:”A”;i:1;s:1:”A”;}

    I really can’t save this flexible fields contained in repeater field.
    Nobody has already did that?

  • Hello Elliot,
    in your tutorial you say to transalte Field Groups and do nothing on Fields.
    But in the WPML options I can’t find any “fields” option, just Fields Groups.
    (screenshot: http://prntscr.com/6fep16)

    Maybe this happens because I’m using the WPML Translation Management addon to use icanlocalize professional translations.

    I’ve also marked as “translate” all the custom fields as you say in the part “avoid data loss”.

    When I send to professional translators this contents, they are able to translate all the fields, and I get this fields translated in the WPML translations editor interface (screenshot: http://prntscr.com/6feo1g)

    But If I open the post normally, in the standard WP edit interface, fields are not there (screenshot: http://prntscr.com/6feog9)

    I understand that this is also a WPML issue and that they should help as well, but unfortunately any request about ACF in WPML forum is answered with this sentence “ACF is not in our compatibility list, you should use Types instead of ACF”…

    Is there someone able to make repeater and flexible fields translatable by icanlocalize professionals?

  • You’re surely right foxviewr, I already tested regressing to previous WPML version and reported the issue to WPML suppor forum (where I found huge amount of people in similar situation).

    I just felt that was good to report this issue here too, for some reason even with the buggy last version of WPML, if I use ACF 4.4.0 with repeater and flexible content addons, instead of ACF Pro, everything looks fine.

  • It seems that the last version of WPML is causing this issue. There are a huge amount of support request on WPML forum after last update. They say to be aware about this and that they will fix the issue asap, maybe today. I really hope it’s not an ACF fault, I’m deeply in love with this plugin 🙂

  • Many Many thanks thisislawatts!
    your hack worked as a charm.

    I’m a big fan of ACF, but this is quite disappointing. I did not have any asnwer from official support, not even a notice about the missing db upgrade.

  • Sorry to bump this, but I can’t figure out how to fix this.

Viewing 22 posts - 1 through 22 (of 22 total)