Support

Account

Home Forums Backend Issues (wp-admin) [field USER] Add email next to name on ajax results returned Reply To: [field USER] Add email next to name on ajax results returned

  • Thank you!
    For others here is what I did.

    add_filter('acf/fields/user/result', 'my_acf_fields_user_text', 10, 4);
    function my_acf_fields_user_text($text, $user, $field, $post_id){
        
        $args = array(
            'post_type' => 'MY_POST_TYPE',
            'order' => 'DESC',
            'posts_per_page' => 5,
            'paged' => 1,
            'meta_query' => array(  
                'relation' => 'AND',
                array(
                    'key' => 'user_name',
                    'value' =>$user->ID,
                    'compare' => '=',
                ),
                array(
                    'key' => 'META_TO_COMPARE',
                    'value' =>0,
                    'compare' => '=',
                ),
            ),
        );
        $posts = new WP_Query( $args );
        $nb_posts = $posts->found_posts;
    
        $text .= ' - ' . $user->user_email .  ' [' . $nb_posts . ' posts]';
    
        return $text;
    
    }