WordPress filter hook · part of WordPress core

comment_text

A WordPress core filter that 77 plugins also fire themselves, running on 7.6M+ sites between them.

“This filter is documented in wp-includes/comment-template.php”

How to use comment_text

It's a filter: your callback receives the value and 1 more argument, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'comment_text', function( $comment_content, $comment ) {
	// Change $comment_content here.
	return $comment_content;
}, 10, 2 );

Argument names come from GeoDirectory's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

77 plugins that fire comment_text

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'comment_text', $comment_text, $comment, $args ) src/Blocks/BlockTypes/Reviews/ProductReviewContent.php:48
  2. Gutenberg icon Gutenberg400,000+ installs apply_filters( 'comment_text', $comment_text, $comment, $args ) build/scripts/block-library/comment-content.php:37
  3. Comments icon Comments60,000+ installs apply_filters( 'comment_text', $commentContent, $comment, ["is_wpdiscuz_comment" => true] ) class.WpdiscuzCore.php:807
  4. AI icon AI60,000+ installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment, array() ) includes/Experiments/Markdown_Feeds/Markdown_Comment_Renderer.php:256
  5. WPGraphQL icon WPGraphQL30,000+ installs apply_filters( 'comment_text', $content, $this->data ) src/Model/Comment.php:153
  6. GeoDirectory icon GeoDirectory10,000+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) includes/api/class-geodir-rest-reviews-controller.php:778
  7. WordPress REST API (Version 2) icon WordPress REST API (Version 2)10,000+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) lib/endpoints/class-wp-rest-comments-controller.php:591
  8. WP-Print icon WP-Print8,000+ installs apply_filters( 'comment_text', $content, null, array() ) includes/class-wp-print-content.php:254
  9. ActivityPub icon ActivityPub6,000+ installs apply_filters( 'comment_text', $content, $comment, array() ) includes/transformer/class-comment.php:148
  10. PublishPress Planner icon PublishPress Planner6,000+ installs apply_filters( 'comment_text', $theComment->comment_content, $theComment ) modules/editorial-comments/editorial-comments.php:1047
  11. WPMobile.App icon WPMobile.App3,000+ installs apply_filters( 'comment_text', $comment_text, $e ) themes/wpappninja-full/comments.php:38
  12. WP-Stats icon WP-Stats2,000+ installs apply_filters( 'comment_text', $comment->comment_content ) includes/class-wp-stats-page.php:535
  13. Simple Comment Editing icon Simple Comment Editing2,000+ installs apply_filters( 'comment_text', apply_filters( 'get_comment_text', $comment_content_to_return, $comment, array() ), $comment, array() ) includes/Functions.php:84
  14. Liveblog icon Liveblog2,000+ installs apply_filters( 'comment_text', $content, $comment ) classes/class-wpcom-liveblog-entry.php:276
  15. OpenStation icon OpenStation1,000+ installs apply_filters( 'comment_text', $comment->comment_content, $comment, array() ) includes/my-wordpress/comment-stats.php:203
  16. GoodBarber icon GoodBarber1,000+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:24
  17. AppPresser icon AppPresser900+ installs apply_filters( 'comment_text', $child->comment_content, $child ) inc/AppPresser_Extend_Comments.php:65
  18. FluentComments icon FluentComments800+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) app/Services/CommentsRepository.php:144
  19. Mihdan: Ajax Edit Comments icon Mihdan: Ajax Edit Comments300+ installs apply_filters( 'comment_text', apply_filters('get_comment_text',AECUtility::encode($comment['comment_content'])) ) lib/class.ajax.php:395
  20. Wp-Adv-Quiz icon Wp-Adv-Quiz200+ installs apply_filters( 'comment_text', $postBoxQuizDescription ) lib/view/WpAdvQuiz_View_FrontQuiz.php:627
  21. WP-UserAgent icon WP-UserAgent200+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) wp-useragent.php:203
  22. WP Forum Server icon WP Forum Server100+ installs apply_filters( 'comment_text', $this->output_filter($post->text) ) wpf.class.php:960
  23. CM Download Manager icon CM Download Manager100+ installs apply_filters( 'comment_text', $content ) lib/models/SupportThread.php:283
  24. XHTheme AI Toolbox icon XHTheme AI Toolbox100+ installs apply_filters( 'comment_text', get_comment_text($comment), $comment, [] ) classes/class-xhtheme-comment-security.php:32
  25. Recent Comments Widget with Comment Excerpts icon Recent Comments Widget with Comment Excerpts100+ installs apply_filters( 'comment_text', $recent_comment->comment_content ?? '' ) recent_comments_widget_with_excerpts.php:103
  26. AcrossAI Abilities Manager icon AcrossAI Abilities Manager100+ installs apply_filters( 'comment_text', $comment->comment_content, $comment, array() ) includes/Abilities/Comments/Comment_Formatter.php:48
  27. Comment Mail icon Comment Mail100+ installs apply_filters( 'comment_text', $markup, $comment, [] ) src/includes/classes/UtilsMarkup.php:773
  28. IdeaPress icon IdeaPress70+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  29. Advanced Comments Widget icon Advanced Comments Widget60+ installs apply_filters( 'comment_text', $comment_content, $comment, $instance ) inc/class-acw-recent-comments-utilities.php:809
  30. Epoch icon Epoch60+ installs apply_filters( 'comment_text', $comment[ 'comment_content' ], (object)$comment ) classes/front/api_helper.php:82
  31. BuddyPress Groupblog icon BuddyPress Groupblog50+ installs apply_filters( 'comment_text', $comment->comment_content ) themes/p2/functions.php:253
  32. Nexvio for WooCommerce icon Nexvio for WooCommerce50+ installs apply_filters( 'comment_text', $r->comment_content, $r, array() ) includes/class-nexvio-reviews.php:192
  33. Appeto icon Appeto50+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) json-api/models/comment.php:23
  34. Recent Comments Widget with Excerpts icon Recent Comments Widget with Excerpts50+ installs apply_filters( 'comment_text', $comment->comment_content ) recent_comments_widget_with_excerpts.php:101
  35. Acadlix LMS icon Acadlix LMS50+ installs apply_filters( 'comment_text', $quiz->post_content ) includes/Common/Assets/Manager.php:125
  36. replyMail icon replyMail40+ installs apply_filters( 'comment_text', $content ) getdata.php:57
  37. Ajax Comment Preview icon Ajax Comment Preview40+ installs apply_filters( 'comment_text', $text ) ajax-comment-preview.php:121
  38. Post From Site icon Post From Site40+ installs apply_filters( 'comment_text', $content ) pfs-submit.php:136
  39. Expandable Dashboard Recent Comments icon Expandable Dashboard Recent Comments30+ installs apply_filters( 'comment_text', apply_filters( 'get_comment_text', $comment->comment_content ), '40' ) expandable-dashboard-recent-comments.php:207
  40. BP Restrict Signup by Email Domain icon BP Restrict Signup by Email Domain30+ installs apply_filters( 'comment_text', sprintf( str_replace( array( '{{domains}}', '{{adminemail}}' ), array( '%1$s', '%2$s' ), $settings['registration_msg'] ), '<strong>' . implode( ', ', $allowed_domains ) . '</strong>', antispambot( bp_get_option( 'admin_email' ) ) ) ) bp-rsed.php:126
  41. Reactor: Core icon Reactor: Core30+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) json-rest-api/lib/class-wp-json-comments.php:133
  42. PZZ API Client icon PZZ API Client20+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) includes/lib/class-pzz-json-comments.php:66
  43. Themofy Addons for Elementor icon Themofy Addons for Elementor10+ installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment, [] ) modules/woocommerce/includes/class-reviews.php:303
  44. bbPress Post via Mail icon bbPress Post via Mail10+ installs apply_filters( 'comment_text', get_comment_text( $comment ) ) library/pvm/Connector/WordPress.php:320
  45. Bootstrap Devnia PM based on Cartpauj-PM wordpress icon Bootstrap Devnia PM based on Cartpauj-PM wordpress10+ installs apply_filters( 'comment_text', $this->autoembed($this->output_filter($post->message_contents)) ) pm-class.php:404
  46. Fundrizer Lite icon Fundrizer Lite10+ installs apply_filters( 'comment_text', $content, $this->data ) deps/wp-graphql/src/Model/Comment.php:140
  47. RESTful JSON API icon RESTful JSON API10+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:28
  48. JoeMobi icon JoeMobi10+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:45
  49. Mage Reviews icon Mage Reviews10+ installs apply_filters( 'comment_text', $comment->comment_content ) cast/mage-reviews.php:112
  50. Clickio Prism icon Clickio Prism10+ installs apply_filters( 'comment_text', $comment_content, $comment, [] ) src/Meta/PostMeta.php:162
  51. SiaraShield icon SiaraShield10+ installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment ) siarashield.php:296
  52. prograpper icon prograpper10+ installs apply_filters( 'comment_text', $comment->comment_content, $comment ) wp-api/lib/class-wp-json-comments.php:133
  53. bizconnector icon bizconnector10+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  54. FEP Contact Form icon FEP Contact Form10+ installs apply_filters( 'comment_text', $html ) functions.php:356
  55. Android and iOS App plugin for WooCommerce by WSD icon Android and iOS App plugin for WooCommerce by WSD10+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  56. Architrave Extras icon Architrave Extras10+ installs apply_filters( 'comment_text', $c->comment_content, $c, array() ) inc/markdown.php:157
  57. BP Blacklist Signup by Email Domain icon BP Blacklist Signup by Email Domain10+ installs apply_filters( 'comment_text', sprintf( str_replace( array( '{{domains}}', '{{adminemail}}' ), array( '%1$s', '%2$s' ), $settings['registration_msg'] ), '<strong>' . implode( ', ', esc_url($allowed_domains) ) . '</strong>', antispambot( bp_get_option( 'admin_email' ) ) ) ) bp-blacklist-signup-by-email-domain.php:130
  58. MobPress icon MobPress10+ installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  59. Modern Comments icon Modern CommentsFewer than 10 installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment, array() ) includes/Frontend/CommentRenderer.php:111
  60. CommentarySandbox icon CommentarySandboxFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content ) commentpress-core/assets/includes/theme/theme-functions.php:2225
  61. CommentAura icon CommentAuraFewer than 10 installs apply_filters( 'comment_text', $result->comment_content, $result ) src/Rest/CommentEditController.php:137
  62. Feature Request System icon Feature Request SystemFewer than 10 installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment, [] ) src/Comments/CommentThread.php:119
  63. GSheetConnector icon GSheetConnectorFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content ) includes/pages/class-wp-core-services.php:968
  64. Hibira Realtime icon Hibira RealtimeFewer than 10 installs apply_filters( 'comment_text', get_comment_text( $comment ), $comment, array() ) includes/class-hibira-comments.php:42
  65. Support Portal icon Support PortalFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment, [] ) templates/topic-single.php:141
  66. Hatch Connect icon Hatch ConnectFewer than 10 installs apply_filters( 'comment_text', $c->comment_content, $c ) includes/class-headless-comments.php:97
  67. HameThread icon HameThreadFewer than 10 installs apply_filters( 'comment_text', get_comment_text( $this->comment ), $this->comment, [] ) app/Hametuha/Thread/Model/CommentModel.php:36
  68. Anonelio icon AnonelioFewer than 10 installs apply_filters( 'comment_text', get_comment_text($comment), $comment, $args ) anonelio-anonymous-forum-comments.php:250
  69. CookPal Reader Engagement icon CookPal Reader EngagementFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment, array() ) public/class-cookpal-public.php:835
  70. WP-Restify icon WP-RestifyFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment ) include/class-wp-json-comments.php:133
  71. NutNote for wordpresss icon NutNote for wordpresssFewer than 10 installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  72. WP eCommerce Betaout icon WP eCommerce BetaoutFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment ) lib/class-wp-json-wpecproduct.php:1428
  73. Gallop icon GallopFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment, [] ) src/Rest/CommentsEndpoint.php:474
  74. bSocial comments icon bSocial commentsFewer than 10 installs apply_filters( 'comment_text', get_comment_text( $comment_id ), get_comment( $comment_id ), array() ) components/class-bsocial-comments-featured.php:516
  75. Foliodock API icon Foliodock APIFewer than 10 installs apply_filters( 'comment_text', $wp_comment->comment_content ) models/comment.php:23
  76. Reader’s Web Publisher icon Reader’s Web PublisherFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content, $comment ) includes/comments-json.php:65
  77. User Agent Displayer icon User Agent DisplayerFewer than 10 installs apply_filters( 'comment_text', $comment->comment_content ) agent.php:338

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.