Title: comment_ID()
Last modified: August 19, 2016

---

# comment_ID()

 *  Resolved [bonnerl17](https://wordpress.org/support/users/bonnerl17/)
 * (@bonnerl17)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/)
 * I’m designing a plugin and as part of what it does it’s going to change what 
   comment_author_link() returns, and as part of it I need the user’s ID number.
   But when I try to use comment_ID() it echo’s/prints it no matter where I put 
   it. (Note: I’m using comment_ID() when I query the database to get the comment
   authors #ID, so if you know a better way to get their #ID I’d be glad to hear
   about it!)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/#post-669639)
 * Well… which are you trying to get? The User’s ID or the Comment’s ID? These are
   not the same things.
 * Anyway, you can use get_comment_ID() to get the comment ID back instead of echoing
   it.
 *  Thread Starter [bonnerl17](https://wordpress.org/support/users/bonnerl17/)
 * (@bonnerl17)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/#post-669685)
 * I’m needing the users ID.
 * > Anyway, you can use get_comment_ID() to get the comment ID back instead of 
   > echoing it.
 * Thanks.
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/#post-669782)
 * The problem is that the users ID is not stored with the comment. It only stores
   the user name, email, url with the comment. If you want to link that info to 
   a user, you’ll probably need some custom SQL.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/#post-669795)
 * Actually, the user ID _is_ stored with a comment (under the column `user_id`).
   So within the comment loop:
 * `$comment->user_id`
 * will hold it. That is, if the comment is from a logged in user on your blog. 
   Otherwise the value will be null.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘comment_ID()’ is closed to new replies.

 * 4 replies
 * 3 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [18 years, 5 months ago](https://wordpress.org/support/topic/comment_id/#post-669795)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
