Home › Forums › Add-ons › Repeater Field › Sort order Repeater Users › Reply To: Sort order Repeater Users
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() https://codex.wordpress.org/Function_Reference/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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.