Support

Account

Forum Replies Created

  • Hi! Thank you for the quick response πŸ™‚

    @jarvis I didn’t know about this! It’s interesting. I tried it and it indeed makes the field group disappear from those available for sync. Problem is that if I save the field group again (which I do all the time), the private value will disappear and they’ll start automatically syncing again. I think it would work if there was a way to check a “private” checkbox directly from the field group edit page, but I’m not sure how to do it.

    @hube2 What I have is a multisite with a main theme, and every subsite has a child theme. Each subsite has an options page with three subpages (each of them containing one field group). I want to sync only one of those subpages, the other two need to be modified frequently to fit their site’s needs.

    In the main theme’s functions.php, I put two things: a filter to change the saving location of the JSON, and another one to change the loading location, like this:

    
    add_filter('acf/settings/save_json', 'my_acf_json_save_point');
    function my_acf_json_save_point($path) {
        // update path
        $path = get_template_directory() . '/custom-fields';
        
        // return
        return $path;
    }
    
    // changes loading location for custom fields
    add_filter('acf/settings/load_json', 'my_acf_json_load_point');
    function my_acf_json_load_point( $paths ) {
        // remove original path (optional)
        unset($paths[0]);
        
        // append path
        $paths[] = get_template_directory() . '/custom-fields';
        
        // return
        return $paths;
    }

    Hope that’s clear! Again, thank you for your help

  • Yeah, I ended up manually creating a field in the database and updating it with this. Perfect for what I needed πŸ™‚

  • I see. Thank you for taking the time to help me out πŸ™‚

  • Yes! You were right. I have some other stuff in functions.php, so I tried putting your piece of code at the top of it and it worked. Then I narrowed it down by putting it after each function and test it to see when it actually broke. Turns out if I put it after my custom toolbar links, it doesn’t work. The hook looks like this (used this tutorial):

    add_action('admin_bar_menu', 'custom_toolbar_link', 999);

    I assume 999 is the priority, and it must be the source of the issue?

  • Thank you, it doesn’t seem to be doing anything either though. Still nothing in the log πŸ™

  • Thank you for your response! It’s not running at all. The text of the second function I try to output in the log doesn’t even show.

  • It’s on all fields, but I have multiple fields I need to hide that have the same name (they’re in repeaters). Maybe this could be related?

  • Nice, I didn’t know this existed! It works, although I get a PHP notice when it doesn’t render the field:

    Notice: Trying to access array offset on value of type bool in /home/website/www/wp-content/plugins/user-role-field-setting-for-acf/acf-user-role-field-setting.php on line 47

    Anything I could do about it?

  • Alright, I came up with something if anybody stumbles upon this topic and has the same problem. Basically, I’m hiding the fields I want to disable using CSS when they’re disabled in the main options page.

    Here goes in functions.php:

    // ACF admin CSS
    function acf_css() { ?>
        <style type="text/css">
    
        /* checks if option is checked on main option page*/
        <?php if (!get_field('papier', 'options')) { ?>
            
            /* hides option in admin */
            th[data-name="cache_papier"], td[data-name="cache_papier"] {
                display: none;
            }
    
        <?php } ?>
    
        </style>
        <?php
    }
    
    // adds the CSS above to ACF's admin
    add_action('acf/input/admin_head', 'acf_css');

    Of course you need to replace get_field(‘papier’, ‘options’) for the field that disables the other, as well as data-name=”cache_papier” for the field to hide, with your own names if you do it this way. I hope that’s clear πŸ™‚

    It’s not perfect since it’s not actually disabled, it’s just hidden, but it’s better than nothing.

  • Hi John, thank you for your response.

    Indeed, they’re on two different option pages.

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

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.