I’m sure there is something stupid missing, but I’m tired and cannot comprehend exactly what.
I’ve an array which print_rs just fine:
Array ( [0] => stdClass Object ( [comment_ID] => 20 [comment_post_ID] => 227 [comment_author] => admin [comment_author_email] => [comment_author_url] => [comment_author_IP] => ::1 [comment_date] => 2012-07-29 14:19:34 [comment_date_gmt] => 2012-07-29 14:19:34 [comment_content] => I'm attending this Event! [comment_karma] => 0 [comment_approved] => 1 [comment_agent] => [comment_type] => [comment_parent] => 0 [user_id] => 1 ) )
p.s. removed some values for privacy.
Now I want to get comment_ID, but nothing outputs to browser.
php looks like this:
$current_user_comment = get_comments( array(
'post_id' => $post->ID,
'user_id' => get_current_user_id(),
'number' => 1,
'status' => 'approve',
'type' => 'comment'
) );
print_r ( $current_user_comment );
echo $current_user_comment->comment_ID;
As you can see from the output of
print_r,$current_user_commentis array, not an object. And desired object is at index0in that array.$current_user_comment[0]->commentIDwill work.