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;
}
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.