Home Forums Add-ons Repeater Field Sort order Repeater Users


Sort order Repeater Users

  • Hi

    I’m using Repeater with Field type “Select” and object “Users” for Author on Post.
    Setting Repeater
    I got problem that the list users show when select a Author is not sorted.
    not sorted

    Is there anyone can help me how to sort that list Author by alphabet on Post backend page?


  • There are filters in the user field that will let you change the sort order, the code in acf looks something like this

    // filters
    $args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']);
    $args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']);
    $args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']);

    $args is the same as used in the wp function get_users()

    add_filter('acf/fields/user/query/name=user_field_name', 'change_user_order_by', 10, 3);
    function change_user_order_by($args, $field, $post_id) {
      $args['orderby'] = 'display_name';
      return $args;
  • Hi John

    Thank you very much. I solved my issue with your reply.
    Appreciate your help.

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

The topic ‘Sort order Repeater Users’ is closed to new replies.