Support

Account

Forum Replies Created

  • Hey Elliot,

    We thought about the JS method, yeah. But we figured out another workaround. I created all the reports with all the layouts once, added them to user “Demo”, added a menu-item to that users’ post list and intergrated a Duplicate Post plugin. Now the teachers don’t have to make every report themselves, but that can copy a new draft from one of the standard posts I’ve put in.

    This works well for us. Shame we didn’t get it figured out anyhow, but thanks for your effort, time and fantastic work!!

  • Hey Elliot,

    I work with a developer (I’m a designer myself), he’s pretty skilled in WordPress filters and all that. Still we are having problems to apply the filter to the flexible content fields.

    We did get default values in non-flexible content fields, using this code:

    function my_acf_load_value( $value, $post_id, $field )
    {
        // run the_content filter on all textarea values
        $value = "1"; 
     
        return $value;
    }
    
    add_filter('acf/load_value', 'my_acf_load_value', 10, 3);
    

    The problem here is that the flexible content field isn’t mentioned anywhere. When we tried this, we had no luck

    add_filter('acf/load_value/type=flexible_content', 'my_acf_load_value', 10, 3);

    – I’m just gonna think out loud from here –
    My point is, we can get the filter to work, but how can we apply it to the flexible content so that they are expanded by default?

    (how) Do we apply the filter to the subfields?

    Our fields are set like this:
    – Flexible content field
    — Subfield
    — Checkbox ‘r1’
    — Checkbox ‘r2’
    — Subfield
    — Textfield ‘r1’
    — Textfield ‘r2’
    — Subfield
    etc. etc.

    I imagine it wouldn’t be wise to apply the filter to a fieldname such as ‘r1’ because they could be checkboxes or textfields. Thus I think we have to apply the filter to the field_type, mostly being textfields and checkboxes.

    Meaning I could use this:
    add_filter('acf/load_value/type=checkbox', 'my_acf_load_value', 10, 3);
    To add default values to checkboxes. But we need to know how to apply this filter not to checkboxes, but to checkboxes in flexible content fields (or all checkboxes for all I care) – as long as the fields are shown by default.

    Furthermore I wanted to thank you for a fantastic product. We use it allot and overall it’s going really smooth. I realize we’re asking some pretty specific stuff here. I just hope we can figure this out (for our client’s sake).

  • Hey Elliot,

    Thanks for the reply, but I dont fully understand (yet). Adding dummy data like this is different from adding a default value to a field right? Because when I do that, I still have to manually add every item.

    I read the docs but they are very unclear to me. This is the code I added to see what would happen, and I got a whole bunch of errors.

    function my_acf_load_value( $value, $post_id, $field )
    {
        // run the_content filter on all textarea values
        $value = apply_filters('the_content',$value); 
     
        return $value;
    }
      
    // acf/load_value/type={$field_type} - filter for a value load based on it's field type
    add_filter('acf/load_value/type=checkbox', 'my_acf_load_value', 10, 3);
    

    This is the most of the errors I get

    preg_split() expects parameter 2 to be string, array given in on line : Invalid argument supplied for foreach() in on line : implode() []: Invalid arguments passed in on line : 
    
    Warning
    : implode() [
    function.implode
    ]: Invalid arguments passed in
    /home/rapport/domains/rapport.pro/public_html/wp-includes/formatting.php
    on line
    130
    

    Almost all fields are checkboxes or text-fields. I cant seem to understand the function, in the docs it declares $value as $value (??) and the $field is never used in the code?

    I’m kinda newbie to all this :$

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