Author name length character limit?
-
14-04-2021 - |
Question
In comments, I want to limit author names. For example, the author's name should be no more than 10 characters. I'm looking for a way to do this. Thank you very much in advance.
Solution
There's a filter called get_comment_author
that you can hook into to modify a comment author's appearance.
add_filter( 'get_comment_author', function( $author, $comment_id, $comment ) {
// limit to first 10 characters
$author = substr( $author, 0, 10 );
return $author;
}, 10, 3 );
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange