Created
March 25, 2018 00:33
-
-
Save versluis/bf74b1f411133dac50e47abc0b5f2d7b to your computer and use it in GitHub Desktop.
get word count from comments written by the current user in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getWordCountCommentsCurrentUser() { | |
$count = 0; | |
$user_id = get_current_user_id(); | |
$comments = get_comments( array( | |
'user_id' => $user_id | |
)); | |
foreach( $comments as $comment ) { | |
$count += str_word_count( $comment->comment_content ); | |
} | |
return $count; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment