简体   繁体   中英

accessing an element within a php object within an array of objects

I am hooking into a wordpress plugin and it is returning an object - $data. I think the structure of it is below. I did a error_log( print_r( $data, true ) ); to get that structure because I can only access the server logs because it's wordpress

This is the important part. How can I access the user_email variable inside the class. tried searching the web with no luck. Thanks

Array
    (    
    [user] => WP_User Object
            (
        [data] => stdClass Object
                    (
            [ID] => 18
                    [user_login] => somedatahereremovedbyme
                    [user_pass] => somedatahereremovedbyme
                        [user_nicename] => somedatahereremovedbyme-com
                        [user_email] => somedatahereremovedbyme.com
                        [user_url] =>                     
            [user_registered] => 2017-10-09 05:41:19
                        [user_activation_key] => 1507527679:$P$Be3gmAdSS7jMH25OpIwGd/hH5Hriua.
                    [user_status] => 0
                        [display_name] => somedatahereremovedbyme
                )  

尝试:

$user_email = $data['user']->data->user_email;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM