Home / admin / Automatically add a signature to admin comments
  • How to Automatically add a signature to admin comments

    automatically-add-a-signature-to-admin-comments

    Adding this code to the functions.php of your wordpres theme will display a signature after each admin comment. You may need to update the ID number, the default is set to ‘1’ and of course change the text displayed within the signature.

    Update: was an issue with the snippet, have just recently updated and tested it and is working on the newest version of wordpress.

    ( click code to copy )

    wordpress snippet : PHP

    <>
    add_filter( 'comment_text', 'my_comment_text' );
    function my_comment_text( $mytext ) {
    	$id = get_comment(get_comment_ID())->user_id;
    	global $comment;
    	if($id == 1 ){
    		$mytext = get_comment_text( $comment ) . '<hr />Test comment text!';
    	}else{
    		$mytext = get_comment_text( $comment );
    	}
    	return $mytext;
    }
    

    ( WordPress codex functions, hooks, in this snippet. )

    comment_text, get_comment_ID, get_comment_text, get_comment, comment_ID, add_filter,
  • Ttomp13

    Doesn’t work, bro. Displays signature for ALL comment authors… not just admins.

    • Hi Ttomp,
      Your right was not sure what I was up to that day lol, anyway I updated the snippet and it is working properly now.