get_users(…) only returns one user The 2019 Stack Overflow Developer Survey Results Are In2019 Community Moderator ElectionBest way to get user id for get_users function?Get multiple roles with get_usersget_users is expecting unserialized meta_valueHow to do get_users() with multiple meta_keysHow to get the user description with get_users?get_users meta_querySort get_users by custom fieldget_users() ORDER BY Not WorkingGet_Users Orderby Pageget_users by role returns all users

Correct punctuation for showing a character's confusion

Is it okay to consider publishing in my first year of PhD?

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

If I score a critical hit on an 18 or higher, what are my chances of getting a critical hit if I roll 3d20?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Can an undergraduate be advised by a professor who is very far away?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Are spiders unable to hurt humans, especially very small spiders?

Is it a good practice to use a static variable in a Test Class and use that in the actual class instead of Test.isRunningTest()?

Cooking pasta in a water boiler

How to support a colleague who finds meetings extremely tiring?

What to do when moving next to a bird sanctuary with a loosely-domesticated cat?

Falsification in Math vs Science

Why are there uneven bright areas in this photo of black hole?

Inverse Relationship Between Precision and Recall

Can there be female White Walkers?

Pokemon Turn Based battle (Python)

What does もの mean in this sentence?

Dropping list elements from nested list after evaluation

Mathematics of imaging the black hole

Why does the nucleus not repel itself?

If my opponent casts Ultimate Price on my Phantasmal Bear, can I save it by casting Snap or Curfew?

Why couldn't they take pictures of a closer black hole?

What is this business jet?



get_users(…) only returns one user



The 2019 Stack Overflow Developer Survey Results Are In
2019 Community Moderator ElectionBest way to get user id for get_users function?Get multiple roles with get_usersget_users is expecting unserialized meta_valueHow to do get_users() with multiple meta_keysHow to get the user description with get_users?get_users meta_querySort get_users by custom fieldget_users() ORDER BY Not WorkingGet_Users Orderby Pageget_users by role returns all users



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) is only returning me 1 users though it should return 3. What am I doing wrong?



var_dump($targetUsersIDs);
$targetUsers = get_users(['include' => $targetUsersIDs]);
var_dump($targetUsers);


Output of var_dump($targetUsersIDs);




array (size=3)
0 =>
object(stdClass)[4785]
public 'ID' => string '1' (length=1)
1 =>
object(stdClass)[4784]
public 'ID' => string '2' (length=1)
2 =>
object(stdClass)[4783]
public 'ID' => string '4' (length=1)



Start of the output of var_dump(targetUsers);




array (size=1)
0 =>
object(WP_User) ...










share|improve this question









New contributor




TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


























    1















    I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) is only returning me 1 users though it should return 3. What am I doing wrong?



    var_dump($targetUsersIDs);
    $targetUsers = get_users(['include' => $targetUsersIDs]);
    var_dump($targetUsers);


    Output of var_dump($targetUsersIDs);




    array (size=3)
    0 =>
    object(stdClass)[4785]
    public 'ID' => string '1' (length=1)
    1 =>
    object(stdClass)[4784]
    public 'ID' => string '2' (length=1)
    2 =>
    object(stdClass)[4783]
    public 'ID' => string '4' (length=1)



    Start of the output of var_dump(targetUsers);




    array (size=1)
    0 =>
    object(WP_User) ...










    share|improve this question









    New contributor




    TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.






















      1












      1








      1








      I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) is only returning me 1 users though it should return 3. What am I doing wrong?



      var_dump($targetUsersIDs);
      $targetUsers = get_users(['include' => $targetUsersIDs]);
      var_dump($targetUsers);


      Output of var_dump($targetUsersIDs);




      array (size=3)
      0 =>
      object(stdClass)[4785]
      public 'ID' => string '1' (length=1)
      1 =>
      object(stdClass)[4784]
      public 'ID' => string '2' (length=1)
      2 =>
      object(stdClass)[4783]
      public 'ID' => string '4' (length=1)



      Start of the output of var_dump(targetUsers);




      array (size=1)
      0 =>
      object(WP_User) ...










      share|improve this question









      New contributor




      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I have an array of user IDs, I want to get data for each of these users. I first thought of writing a classic SQL query but I found WordPress has integreted functions for it. However, get_users(...) is only returning me 1 users though it should return 3. What am I doing wrong?



      var_dump($targetUsersIDs);
      $targetUsers = get_users(['include' => $targetUsersIDs]);
      var_dump($targetUsers);


      Output of var_dump($targetUsersIDs);




      array (size=3)
      0 =>
      object(stdClass)[4785]
      public 'ID' => string '1' (length=1)
      1 =>
      object(stdClass)[4784]
      public 'ID' => string '2' (length=1)
      2 =>
      object(stdClass)[4783]
      public 'ID' => string '4' (length=1)



      Start of the output of var_dump(targetUsers);




      array (size=1)
      0 =>
      object(WP_User) ...







      php id get-users






      share|improve this question









      New contributor




      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question









      New contributor




      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question








      edited 2 days ago









      leymannx

      86611122




      86611122






      New contributor




      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 2 days ago









      TTTTTT

      1628




      1628




      New contributor




      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















          4 Answers
          4






          active

          oldest

          votes


















          3














          The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want.






          share|improve this answer








          New contributor




          Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

            – TTT
            2 days ago






          • 1





            @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

            – Julian
            2 days ago











          • Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

            – TTT
            yesterday


















          1














          Somebody has posted this solution and then deleted their post:



          $targetUsers = get_users(['include' => wp_list_pluck($targetUsersIDs,'ID')]);


          It is where I'm using right now.



          Please dn't hesitate to tell me if there's any reason it was wrong (I'm not sure the user has deleted their answer).






          share|improve this answer








          New contributor




          TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















          • Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

            – leymannx
            2 days ago






          • 1





            @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

            – Julian
            2 days ago


















          0














          Do it like this



          var_dump($targetUsersIDs);

          $ids = array();
          foreach ( $targetUsersIDs as $id ) $ids[] = $id;

          $targetUsers = get_users(['include' => $ids ] );
          var_dump($targetUsers);


          I hope this may help.






          share|improve this answer
































            0














            You should be using WP_User_Query for this.



            $user_ids = [ 1, 2, 3, 4, 5 ];

            $args = [
            'include' = $user_ids,
            ]

            $user_query = new WP_User_Query( $args );


            Now you can simply use the result in a user loop/foreach.






            share|improve this answer























              Your Answer








              StackExchange.ready(function()
              var channelOptions =
              tags: "".split(" "),
              id: "110"
              ;
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function()
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled)
              StackExchange.using("snippets", function()
              createEditor();
              );

              else
              createEditor();

              );

              function createEditor()
              StackExchange.prepareEditor(
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader:
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              ,
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              );



              );






              TTT is a new contributor. Be nice, and check out our Code of Conduct.









              draft saved

              draft discarded


















              StackExchange.ready(
              function ()
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f333863%2fget-users-only-returns-one-user%23new-answer', 'question_page');

              );

              Post as a guest















              Required, but never shown

























              4 Answers
              4






              active

              oldest

              votes








              4 Answers
              4






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want.






              share|improve this answer








              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.




















              • I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

                – TTT
                2 days ago






              • 1





                @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

                – Julian
                2 days ago











              • Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

                – TTT
                yesterday















              3














              The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want.






              share|improve this answer








              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.




















              • I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

                – TTT
                2 days ago






              • 1





                @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

                – Julian
                2 days ago











              • Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

                – TTT
                yesterday













              3












              3








              3







              The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want.






              share|improve this answer








              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.










              The include key on get_users requires an array of IDs (numbers). You are giving it an array of objects that have an ID property. If you look at your first var dump you will see this. WP is casting that to a number and returning the user with that number which is not what you want.







              share|improve this answer








              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              share|improve this answer



              share|improve this answer






              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              answered 2 days ago









              JulianJulian

              1313




              1313




              New contributor




              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.





              New contributor





              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              Julian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.












              • I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

                – TTT
                2 days ago






              • 1





                @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

                – Julian
                2 days ago











              • Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

                – TTT
                yesterday

















              • I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

                – TTT
                2 days ago






              • 1





                @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

                – Julian
                2 days ago











              • Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

                – TTT
                yesterday
















              I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

              – TTT
              2 days ago





              I guess it's the right path ... now, looping on the array for($i=0; $i < $targetUsersIDsCount;$i++) $integerTargetUsersIDs[$i] = (int)$targetUsersIDs[$i]; Gives me and array of 3 times 1 (integer)

              – TTT
              2 days ago




              1




              1





              @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

              – Julian
              2 days ago





              @TTT Instead of (int)$targetUsersID[$i] try $targetUsersIDs[$i]->ID. This means: take the ID property of the object in the index $i of the $targetUsersIDs array. Let me know if that helps.

              – Julian
              2 days ago













              Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

              – TTT
              yesterday





              Ah thank you ... now I'm wondering how I didn't see it in the var_dump yesterday. However, somebody gave a more WordPress specific 1-line solution, see the Answer I posted yesterday.

              – TTT
              yesterday













              1














              Somebody has posted this solution and then deleted their post:



              $targetUsers = get_users(['include' => wp_list_pluck($targetUsersIDs,'ID')]);


              It is where I'm using right now.



              Please dn't hesitate to tell me if there's any reason it was wrong (I'm not sure the user has deleted their answer).






              share|improve this answer








              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.




















              • Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

                – leymannx
                2 days ago






              • 1





                @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

                – Julian
                2 days ago















              1














              Somebody has posted this solution and then deleted their post:



              $targetUsers = get_users(['include' => wp_list_pluck($targetUsersIDs,'ID')]);


              It is where I'm using right now.



              Please dn't hesitate to tell me if there's any reason it was wrong (I'm not sure the user has deleted their answer).






              share|improve this answer








              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.




















              • Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

                – leymannx
                2 days ago






              • 1





                @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

                – Julian
                2 days ago













              1












              1








              1







              Somebody has posted this solution and then deleted their post:



              $targetUsers = get_users(['include' => wp_list_pluck($targetUsersIDs,'ID')]);


              It is where I'm using right now.



              Please dn't hesitate to tell me if there's any reason it was wrong (I'm not sure the user has deleted their answer).






              share|improve this answer








              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.










              Somebody has posted this solution and then deleted their post:



              $targetUsers = get_users(['include' => wp_list_pluck($targetUsersIDs,'ID')]);


              It is where I'm using right now.



              Please dn't hesitate to tell me if there's any reason it was wrong (I'm not sure the user has deleted their answer).







              share|improve this answer








              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              share|improve this answer



              share|improve this answer






              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.









              answered 2 days ago









              TTTTTT

              1628




              1628




              New contributor




              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.





              New contributor





              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.






              TTT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.












              • Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

                – leymannx
                2 days ago






              • 1





                @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

                – Julian
                2 days ago

















              • Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

                – leymannx
                2 days ago






              • 1





                @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

                – Julian
                2 days ago
















              Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

              – leymannx
              2 days ago





              Julian's answer explains you why you only got one user returned. Now there's wp_list_pluck() with which you get an array existing merely of user IDs. Which is exactly what include is expecting. Wondering myself why the answer got deleted. It looks just fine. Maybe they were worried about where the $targetUsersIDs array came from in the first place.

              – leymannx
              2 days ago




              1




              1





              @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

              – Julian
              2 days ago





              @TTY this is just a shortcut for what I stated in my comment. Nothing wrong with either solution.

              – Julian
              2 days ago











              0














              Do it like this



              var_dump($targetUsersIDs);

              $ids = array();
              foreach ( $targetUsersIDs as $id ) $ids[] = $id;

              $targetUsers = get_users(['include' => $ids ] );
              var_dump($targetUsers);


              I hope this may help.






              share|improve this answer





























                0














                Do it like this



                var_dump($targetUsersIDs);

                $ids = array();
                foreach ( $targetUsersIDs as $id ) $ids[] = $id;

                $targetUsers = get_users(['include' => $ids ] );
                var_dump($targetUsers);


                I hope this may help.






                share|improve this answer



























                  0












                  0








                  0







                  Do it like this



                  var_dump($targetUsersIDs);

                  $ids = array();
                  foreach ( $targetUsersIDs as $id ) $ids[] = $id;

                  $targetUsers = get_users(['include' => $ids ] );
                  var_dump($targetUsers);


                  I hope this may help.






                  share|improve this answer















                  Do it like this



                  var_dump($targetUsersIDs);

                  $ids = array();
                  foreach ( $targetUsersIDs as $id ) $ids[] = $id;

                  $targetUsers = get_users(['include' => $ids ] );
                  var_dump($targetUsers);


                  I hope this may help.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 days ago

























                  answered 2 days ago









                  Qaisar FerozQaisar Feroz

                  1,4711217




                  1,4711217





















                      0














                      You should be using WP_User_Query for this.



                      $user_ids = [ 1, 2, 3, 4, 5 ];

                      $args = [
                      'include' = $user_ids,
                      ]

                      $user_query = new WP_User_Query( $args );


                      Now you can simply use the result in a user loop/foreach.






                      share|improve this answer



























                        0














                        You should be using WP_User_Query for this.



                        $user_ids = [ 1, 2, 3, 4, 5 ];

                        $args = [
                        'include' = $user_ids,
                        ]

                        $user_query = new WP_User_Query( $args );


                        Now you can simply use the result in a user loop/foreach.






                        share|improve this answer

























                          0












                          0








                          0







                          You should be using WP_User_Query for this.



                          $user_ids = [ 1, 2, 3, 4, 5 ];

                          $args = [
                          'include' = $user_ids,
                          ]

                          $user_query = new WP_User_Query( $args );


                          Now you can simply use the result in a user loop/foreach.






                          share|improve this answer













                          You should be using WP_User_Query for this.



                          $user_ids = [ 1, 2, 3, 4, 5 ];

                          $args = [
                          'include' = $user_ids,
                          ]

                          $user_query = new WP_User_Query( $args );


                          Now you can simply use the result in a user loop/foreach.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 2 days ago









                          leymannxleymannx

                          86611122




                          86611122




















                              TTT is a new contributor. Be nice, and check out our Code of Conduct.









                              draft saved

                              draft discarded


















                              TTT is a new contributor. Be nice, and check out our Code of Conduct.












                              TTT is a new contributor. Be nice, and check out our Code of Conduct.











                              TTT is a new contributor. Be nice, and check out our Code of Conduct.














                              Thanks for contributing an answer to WordPress Development Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid


                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.

                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f333863%2fget-users-only-returns-one-user%23new-answer', 'question_page');

                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Tamil (spriik) Luke uk diar | Nawigatjuun

                              Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                              Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?