Home Forums ACF PRO Extend the User Field Type to add custom filter option


Extend the User Field Type to add custom filter option

  • Working on a membership site where there are multiple branches/locations of members. When a member is registered, they are assigned to a specific branch.

    On the individual Branch pages, we’re creating a repeater field to be able to list the Branch’s Executive team members and their roles. I’d like to be able to use the User field type so that they can select a registered user/member, but ideally we’d be able to filter the list of users to select from by the Branch user meta value.

    Not quite sure how to go about this and any pointers in the right direction would be appreciated.


  • Hi @kmeronuk

    This feature isn’t documented yet (maybe because it isn’t perfect yet), but I believe you can use it. Please use it at your own risk.

    function my_post_object_query( $args, $field, $post )
        // modify the order
        $args['meta_key'] = 'user_meta_key';
        $args['meta_value'] = 'user_meta_value';
        return $args;
    // filter for every field
    add_filter('acf/fields/user/query', 'my_post_object_query', 10, 3);

    I hope this helps.

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

You must be logged in to reply to this topic.