• Resolved Gustav

    (@4ever16)


    Im trying to get comment authors user id how do i do that?

    Here is the comment autput code im trying to manipulate and get comment authors user id from.

    function get_comment_author( $comment_ID = 0 ) {
    	$comment = get_comment( $comment_ID );
    
    	if ( empty( $comment->comment_author ) ) {
    		if ( $comment->user_id && $user = get_userdata( $comment->user_id ) )
    			$author = $user->display_name;		
    		else
    			$author = __('Anonymous');
    	} else {
    		$author = $comment->comment_author;
    		echo $id;
    	}
Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    $user_ID = get_comment( $comment_ID )->user_id;
    If this code is used in context with the current comment, you do not need $comment_ID. If not, $comment_ID needs to somehow be assigned the proper value.

    Thread Starter Gustav

    (@4ever16)

    The file i try to manipulate is wordpress own comment file.
    wp-includes/commment-template.php

    Well i tried what you wrote but it did’t work.

    • This reply was modified 5 years, 2 months ago by Gustav.
    • This reply was modified 5 years, 2 months ago by Gustav.
    • This reply was modified 5 years, 2 months ago by Gustav.
    • This reply was modified 5 years, 2 months ago by Gustav.
    Thread Starter Gustav

    (@4ever16)

    Solved!

    I used this code to help solve my problem.

    $comment->comment_author_email;

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

The topic ‘Comment author user id’ is closed to new replies.