Home Forums Feature Requests Exclude field group from clone field


Exclude field group from clone field

  • I would like to exclude certain fields (or, better still, an entire field group) from being clone-able.

    For example, I have a field group which is used on an options page. This field group (and its associated fields) appear in the list of fields I can choose to clone when creating a clone field. Not only does this clutter the list of clone-able fields, but for cosmetic/usability reasons I simply do not want these fields appearing here.

    I have tried disabling said field group, the result of which is that it does not appear on my options page, but it does still appear in the list of fields that can be cloned.

    Is there already a way to do this?

    Many thanks 🙂

  • If you are using a json file you can set the group to private, this is explained on this page. If you are creating the group in php add the private setting, $group['private'] = 1. If the field group is created some other way you can do this.

    add_filter('acf/get_field_group', 'hide_field_groups', 20);
    function hide_field_groups($group) {
    	if ($group['key'] == 'group_5b586829bb34c') {
    		$group['private'] = 1;
    	return $group;

    But be aware that if you’re using local JSON you will not be able to sync this group.

  • Thank you John.

    I created the group in question via Add New Field Group in WP Admin, and then generated PHP code to instead create it programatically. I then deleted the field group I had created in WP admin. I have tried adding ‘private’ => 1 to the generated code e.g.

    ‘menu_order’ => 0,
    ‘position’ => ‘normal’,
    ‘style’ => ‘seamless’,
    ‘label_placement’ => ‘top’,
    ‘instruction_placement’ => ‘label’,
    ‘hide_on_screen’ => ”,
    ‘active’ => 1,
    ‘description’ => ”,
    ‘private’ => 1

    But this does not have the desired effect. Could you please advise?

    Many thanks,


  • It appears that I was incorrect. It doesn’t work. I did a quick test and thought it was working but it appears I was not totally awake yet when I did the test.

  • This works

    add_filter('acf/get_field_group', 'hide_field_group_from_clone', 20);
    function hide_field_group_from_clone($group) {
    	//ob_start(); echo 'POST'."\r\n";print_r($_POST);error_log(ob_get_clean());
    	if (isset($_POST['action']) && $_POST['action'] == 'acf/fields/clone/query' && $group['key'] == 'group_5b586829bb34c') {
    		return false;
    	return $group;
  • Can confirm this works perfectly, thanks John!

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

The topic ‘Exclude field group from clone field’ is closed to new replies.