Support

Account

Home Forums ACF PRO Hide a field in backend if non admin Reply To: Hide a field in backend if non admin

  • You meant something like:

    function my_acf_add_local_field_groups() {
        acf_add_local_field_group(array(
            'key' => 'group_1',
            'title' => 'My Group',
            'fields' => array (
               array('key' => 'field_1', 'label' => 'Sub Title', 'name' => 'sub_title', 'type' => 'text'),
               if(is_admin()){
                    array('key' => 'field_2', 'label' => 'Sub Title Admin', 'name' => 'sub_title', 'type' => 'text')
               }
            ),
            'location' => array (
                array (
                    array (
                        'param' => 'post_type',
                        'operator' => '==',
                        'value' => 'post',
                    ),
                ),
            ),
        ));
    }
    add_action('acf/init', 'my_acf_add_local_field_groups');