[Support request] How To Add A Verified Badge To Authors and Comment reply

Home Forums Support [Support request] How To Add A Verified Badge To Authors and Comment reply

Home Forums Support How To Add A Verified Badge To Authors and Comment reply

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #2035430
    Aditya Kumaar

    How To Add A Verified Badge To Authors and admin comment reply. Please provide a small code. Like this- Image

    #2035556
    David
    Staff
    Customer Support

    Hi there,

    best i have in my snippets is to add a CSS Class to the Comment if the user is an admin or the post author.

    1. Add this PHP Snippet:

    add_filter( "comment_class", function( $classes, $class, $comment_id, $comment ) {
        if( $comment->user_id > 0 && $user = get_userdata( $comment->user_id ) && ( user_can( $comment->user_id, "administrator" ) || $comment->user_id === $post->post_author ) ) {
            $classes[] = "verified-user";
        }
        return $classes; 
    }, 10, 4 );

    How to add PHP: https://docs.generatepress.com/article/adding-php/

    2. Add this CSS to place some text and a tick beside the comment author name:

    .verified-user .comment-author cite:after {
    	content: 'verifed user \2713';
    	margin-left: 10px;
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.