Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7958907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:29:30+00:00 2026-06-04T04:29:30+00:00

On a WordPress site I’m developing, I have created a fcustom user meta field

  • 0

On a WordPress site I’m developing, I have created a fcustom user meta field (matrix-diagnosis) where people can add additional information.

I’m trying to display a list of all users who have completed this field (and their response), but would like to omit those who have not completed the field.

After a LOT of Googling, the closest I’ve gotten is this bit of code…

<ul class="unstyled">

<?php
  //these are the arguments for the get_users function below
  $args  = array(
     'fields' => 'all_with_meta',
     'meta_query' => array('key' => 'matrix-diagnosis')
  );

  //get_users calls WP_User_Query and returns an array of matching users
  $users = get_users($args);

  //leaving an array of $users sorted by the value of meta 'points'
  foreach ($users as $user) : ?>

     <li>
        <h3><?php the_author_meta( 'first_name', $user->id ); ?> <?php the_author_meta( 'last_name', $user->id ); ?></h3>
        <p><?php the_author_meta( 'matrix-diagnosis', $user->id ); ?></p>
     </li>

<?php endforeach; /* end for each function */ ?>

</ul>

This actually will query the database and display a list of all users and their responses, but if someone has not completed the field, displays just their name. How do I scrub the list of people for whom that field has no value?

I have a hunch the secret lies not in using an array, but in using the $wpdp tag, which I have had no luck with to date.

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:29:31+00:00Added an answer on June 4, 2026 at 4:29 am

    I think you can change the_author_meta( 'matrix-diagnosis', $user->id ); to $matrix_check = get_the_author_meta( 'matrix-diagnosis', $user->id, true ); and on your foreach statment check if empty like:

    foreach ($users as $user) : ?>
    <?php $matrix_check = get_the_author_meta( 'matrix-diagnosis', $user->id, true );
    if ($matrix_check != "") {?>
         <li>
            <h3><?php the_author_meta( 'first_name', $user->id ); ?> <?php the_author_meta( 'last_name', $user->id ); ?></h3>
            <p><?php the_author_meta( 'matrix-diagnosis', $user->id ); ?></p>
         </li>
    

    Note: Not tested, some tags not closed

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a wordpress site and i am trying to add a phpbb3 forum
I have a WordPress site, in which type1 users can upload *.doc files and
I have created a wordpress site. The home page appears in the navigation menu
I have a wordpress site with 5k post and each post has average 25
I have a wordpress site for ex, www.test.com There is a js file (forms.js)in
I have to upgrade a running wordpress site's wordpress CMS and some installed plugins.and
I have wordpress site, i added like button for share post. But, i don't
I have a Wordpress site which has post ratings stored in the wp_ratings table,
I have a wordpress site with jQueryUI tabs applied to two different elements of
Hello I have a wordpress site than I want to upgrade to HTML5 code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.