Home Forums ACF PRO Add filter on the relationship field inside a group Reply To: Add filter on the relationship field inside a group

  • To be honest, I don’t know exactly without testing. I do know that the field name is not what you would expect when calls fires the hook. It does have to do with the hierarchy of the field. I would expect your first example to work, but, it the group field also a sub field of some other field? Is it part of a cloned fields?

    The only way to find out is to create a filter for all fields and output it to see what the name is.

    // all fields filter
    add_filter('acf/prepare_field', 'output_field_object');
    function output_field_object($field) {
      echo '<pre>'; print_r($field); echo '</pre>';
      return $field;

    There have been times when I needed to use the field name and I have had to create my filter for all fields and then use ‘strpos()` to test the field name or even the field key to see if it is the field I need to filter. There is always some logic to it as to why the name is what it is for the filter.

    But for the most part, whenever I am dealing with filtering a sub field of any kind I just use the field key.