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 8681477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:31:12+00:00 2026-06-12T21:31:12+00:00

Possible Duplicate: Able to see a variable in print_r()'s output, but not sure how

  • 0

Possible Duplicate:
Able to see a variable in print_r()'s output, but not sure how to access it in code

How do I pull the ID from the WP_User object inside this array:

Array
(
[0] => Array
    (
        [lid] => WP_User Object
            (
                [data] => stdClass Object
                    (
                        [ID] => 24
                        [user_login] => John Foo
                        [user_pass] => $P$BP0Qa4
                        [user_nicename] => john-foo
                        [user_email] => johnfoo@gmail.com
                        [user_url] => 
                        [user_registered] => 2012-10-10 11:16:24
                        [user_activation_key] => 
                        [user_status] => 0
                        [display_name] => John Foo
                    )

                [ID] => 24
                [caps] => Array
                    (
                        [commissie] => 1
                    )

                [cap_key] => sa_wp_capabilities
                [roles] => Array
                    (
                        [0] => commissie
                    )

                [allcaps] => Array
                    (
                        [edit_posts] => 1
                        [read] => 1
                        [level_1] => 1
                        [level_0] => 1
                        [delete_posts] => 1
                        [commissie] => 1
                    )

                [filter] => 
            )

        [lid_rol] => Voorzitter
    )
)

And I use the following code:

<?php 

$rows = get_field('commissie_lid');
if($rows)
{
    foreach($rows as $row)
    {
        $values = get_field('commissie_lid');
            if($values)
            {
                echo '<ul>'; 
                foreach($values as $value)
                {
                    foreach ($value['lid'] as $liddata) {
                        echo $liddata->ID;                  

                }

               // allways good to see exactly what you are working with
               echo '<pre>';
                   print_r($values);
               echo '</pre>';

            } 
            echo '</ul>';
        } 
    }

}

 ?>

It returns the user id, but also a lot of the following notices:

Notice: Trying to get property of non-object in

Can someone help me?

  • 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-12T21:31:14+00:00Added an answer on June 12, 2026 at 9:31 pm

    I think the problem is here: foreach ($value['lid'] as $liddata) {

    At that point, $value['lid'] is the WP_User object itself, so that foreach ends up iterating over all of the properties of the WP_User object.

    If you eliminate that foreach, you should be able to directly access the public properties of the object from $value['lid'] (e.g. $value['lid']->ID, or $value['lid']->roles[0]).

    Hope that helps.

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

Sidebar

Related Questions

Possible Duplicate: Able to see a variable in print_r()'s output, but not sure how
Possible Duplicate: Able to see a variable in print_r()'s output, but not sure how
Possible Duplicate: Able to see a variable in print_r()'s output, but not sure how
Possible Duplicate: How can I extract images from a PDF file? I am able
Possible Duplicate: Why does this code not increment a counter properly? I have a
Possible Duplicate: how to display data obtained from dao in jsp hi i able
Possible Duplicate: How to invalidate the file system cache? In order to be able
Possible Duplicate: && operator in Javascript In the sample code of the ExtJS web
Possible Duplicate: upload a file to server without using a form? I'am able to
Possible Duplicate: Up, Down, Left and Right arrow keys do not trigger KeyDown event

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.