In version 4 I was using the acf/everything_fields
ajax action to determine if a taxonomy has parents or not. The code for the can be found here: https://github.com/elliotcondon/acf/blob/master/core/controllers/everything_fields.php
Is there an replacement for this controller ?
Thanks
ACF5 is build completely differently than ACF4. To be honest, I can’t tell by looking at the function what in ACF5 may be similar, or even if there is anything similar.
I’m not really sure what this means
to determine if a taxonomy has parents or not
Can you explain more about what you need to do and why?
Hey John, thanks for your reply.
I meant term, not the taxonomy.
I have some required fields defined in my custom fields group. I want these fields only to be applied on the first level (Level 1
) of my terms:
* Root Term
* * Level 1 Term <- Required fields needed and displayed
* * * Level 2 Term <- Required fields not needed here but are displayed
Level 2
has to be still editable but without the required fields.
It seems that in ACF4 the custom fields for the terms were loaded over an xhr request which is no longer the case in ACF5.
It works now. I peeked a bit in the code of the class \acf_form_taxonomy
. There are two methods which were added since version 5, add_term
and edit_term
. There are also two actions defined in which you can hook into: {$taxonomy}_add_form_fields
and {$taxonomy}_edit_form
.
I am using now the actions to determine which term is currently viewed. I save the current term in the $GLOBAS
variable (current hotfix only).
Next, I am using the acf/load_field/name={$field_name}
filter which checks the previously defined term in the $GLOBALS
variable on which level we are and to determine if we display the current field or not.