Support

Account

Home Forums General Issues User with apostrophe in name not found

Helping

User with apostrophe in name not found

  • I have a field (type=’user’).
    I’m trying to select a user with an apostrophe in their name (e.g. O’Henry)
    When I type the user’s name (O’Henry) into the field, I get “No results found”. However, when I type “Henry” into the field, the user is found.

    What do I need to do so searching for “O’Henry” will find the user?

    TIA

  • ACF uses the WP function get_users() with it’s defaults. By default WP only looks in ID, user_ligin, user_email, user_url and user_nicename.

    To look in other fields you’d need to alter the query parameters. This can be done using the hook acf/fields/user/query. I don’t think this one is documented here.

    This is from the ACF code

    
    // 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']);
    

    I think you’ll need to supply custom ‘search_columns’, but I’m not 100% sure

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

You must be logged in to reply to this topic.