Support

Account

Home Forums Backend Issues (wp-admin) Don't show fields on Taxonomy 'add' form. Reply To: Don't show fields on Taxonomy 'add' form.

  • 
    add_filter('acf/location/rule_types', array($this, 'my_acf_location_rule_types'));
    function my_acf_location_rule_types($choices) {
      if (!isset($choices['Other'])) {
        $choices['Other'] = array();
      }
      if (!isset($choices['Other']['post_level'])) {
        $choices['Other']['taxonomy_form'] = 'Taxonomy Form';
      }
      return $choices;
    }
    add_filter('acf/location/rule_values/taxonomy_form', array($this, 'acf_location_taxonomy_form_values'));
    function acf_location_taxonomy_form_values($choices) {
      if (empty($choices)) {
        $choices = array();
      }
      if (!isset($choices['taxonomy_list'])) {
        $choices['taxonomy_admin'] = 'Taxonomy Admin List';
      }
      if (!isset($choices['taxonomy_list'])) {
        $choices['taxonomy_edit'] = 'Taxonomy Term Admin';
      }
      return $choices;
    }
    add_filter('acf/location/rule_match/taxonomy_form', array($this, 'acf_location_taxonomy_form_match'), 10, 3);
    function acf_location_taxonomy_form_match($match, $rule, $options) {
      $current = 'taxonomy_admin';
      if (isset($_GET['tag_ID'])) {
        $current = 'taxonomy_edit';
      }
      switch ($rule['operator']) {
        case '==':
          $match = ($current == $rule['value']);
          break;
        case '!=':
          $match = ($current != $rule['value']);
          break;
        default:
          // do nothing
          break;
      }
      return $match;
    }