0
$comment = get_comment( $comment_id );
$post    = get_post( $comment->comment_post_ID );
$author  = get_userdata( $post->post_author );
$test = "***" . $comment_id . "***" . $post->ID . "***" . $author . "***";

How can I obtain the string $test without getting into the error Object of class WP_Post could not be converted to string?

  • 1
    author->user_email should be $author->user_email. Is that error in your code or just in this question? – Charles Clarkson Oct 31 '13 at 7:17
  • I found the solution while writing the question. I've incorrectly written $author in place of $author->user_email. Anyway I edited my question to make my mistake clear. – Toc Oct 31 '13 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.