Home Forums ACF PRO Change User Select Text


Change User Select Text

  • Currently,

    The Users list shows a list like Username (First Last Name)

    How can I change it to Username (First Last Name – User Custom Field).
    Also How can I search for user custom data in the fancy search select.

  • In ACF5 there is a new filter in the user field that can be used to alter what is displayed, which is not documented. acf/fields/user/result.

    You can see them at line 304 of /fields/user.php

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

    $result => value to be displayed ie, user name
    $user => the user object
    $field => the field object
    $post_id => the current post id

    add_fitler('', 'change_user_display', 10, 4);
    function change_user_display($result, $user, $field, $post_id) {
      // change $result to what you want displayed
      return $result;
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Change User Select Text’ is closed to new replies.