Check If comment author is registered

I wonder if you mean this kind of check:

if( $comment->user_id > 0 ) {
    // Registered comment author
} 

in your comment’s template callback.

This is determined in the the wp-comments-post.php file:

$commentdata = compact('comment_post_ID', ..., 'user_ID' );
$comment_id = wp_new_comment( $commentdata );

but it’s not obvious where the user_ID variable comes from, since this variable is not defined in that file.

So this is actually picking up the global variable $user_ID or $GLOBALS['user_ID'] behind our back 😉

Leave a Comment