The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Identify if the comment was wrriten by current user (2 posts)

  1. Chorley Rocks
    Posted 3 years ago #

    I have a function get_comment_class in comment-template.php. This returns a class for CSS.

    I want to indicate in the comment class if the person who wrote the comment is the same as the person who is logged in. My code is...

    // For comment authors who are logged in as current user
    if ( $wp_user_id = get_current_user_id() ) {
    if ( $comment->user_id === $wp_user_id )
    	$classes[] = 'cuser';

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    It's not working and I don't know why. Can anyone please help?

  2. Chorley Rocks
    Posted 3 years ago #

    I found this worked in all but one case.

    if ( $comment->user_id == get_current_user_id() ) $classes[] = 'cuser';

Topic Closed

This topic has been closed to new replies.

About this Topic