Home Forums Backend Issues (wp-admin) Search in user field


Search in user field

  • Hi,

    I created a custom post type with a user field. I extended the user field with a few extra fields by using the hook acf/fields/user/result (see code below). This works perfectly, but when I want to search in the dropdown it only works for the user name and not the added data. How should I manage that I can search on everything that is added to the dropdown?

    //add company to acf user dropdown
    function change_user_acf_result( $result, $user, $field, $post_id ) {
        $result = $user->user_login;
    	if( $user->first_name ) {
    		$result = $user->first_name;
    		if( $user->last_name ) {
    			$result .= ' ' . $user->last_name;
    	um_fetch_user( $user->ID );
    	$company 	= um_user('installateur-company');
    	$lang 		= um_user('installateur-lang');
    	if($company) $result = $company." - ".$result;
    	if($lang) $result .= ' - ' . $lang;
        return $result;
    add_filter( 'acf/fields/user/result', 'change_user_acf_result', 5, 4 );
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.