This might not directly answer your question (because I haven’t even thought about why the $_POST['submit']
would be ignored or if it is even correct), but you should use filters/actions whenever possible.
The correct filter for filtering comment text is pre_comment_content
, and you should use it like this:
function my_filter_comment_for_swear_words( $comment_content ) {
// Verify if $comment_content contains swear words here
// return $comment_content if it doesn't contain forbidden words
// or wp_die if it does
}
add_filter( 'pre_comment_content', 'my_filter_comment_for_swear_words' );
This code would, as usual, go into your functions.php
file or into your custom plugin (depending on what your setup is).
Related Posts:
- Writing a plugin that notify my friends of new post that mentions(@) them
- Why are two functions over-riding each other?
- Comment `Reply` link doesn’t work if comments are loaded from ajax
- comment_email hook doesn’t seem to work for comment editor field
- Show comments fields in two columns
- preprocess_comment array doesn’t have comment_ID
- How do I alter the comment form ‘allowed tags’ text in a plugin?
- Can wp_list_comments output into variable?
- Comments do not respect display_name setting, how to make plugin to overcome this
- $reverse_top_level works the opposite way according to Codex?
- How to integrate CLEditor to comment system?
- Get attachments from a post
- is pre_get_comments not working?
- How to replace default comments with custom HTML?
- Custom avatars in wordpress comments?
- how to load the comment template from a plugin
- How to get the number of pages when paginating comments?
- How does “Your comment is awaiting moderation” work?
- how to get the top 10 popular blogs
- disable defaault wordpress comments from a plugin
- How to show comments from different Plugins to same post type?
- How to check if `comment_meta` exists before inserting the comment?
- How to get the `comment_post_ID`?
- Email content as comment
- Stop theme displaying comments
- Get Commentor IP When Marking Comment As Spam
- How can a plugin create a page/form in the front end?
- Looking for WordPress System Diagrams
- How to output message during plugin activation
- Init action hook running late after PayPal’s return url?
- Get specific color from admin color scheme
- How do you create a custom edit.php / edit pages page
- Check the Version of an Enqueue’d External Library
- Edit the output of wp_widget_rss_output()
- How to Parse an Array of Elements in Gutenberg Block
- Custom rewrite rule serves content, but returns 404 error code
- How to edit mySQL wp_posts table from plugin php?
- Creating a Wordpess Plugin that writes data to a csv file. The data doesn’t show in the csv file?
- WP_Query with tax_query, order by most ‘matches’
- Using the Settings API, how should I add multiple values to an option?
- WP custom menus error > menu name already exists?
- Problem with is_active_sidebar?
- How to sanitize user input?
- Remove Internal Style Sheet if no Value Provided?
- Widget update function not saving values
- get_the_excerpt() is not returning an empty string when the_excerpt is blank?
- “Plugin could not be activated because it triggered a fatal error.”
- Storing product price data in the database
- Does the order of sections in readme.txt matter?
- Correct check for any admin page with editor
- Add column in WP user but it goes wrong
- modify wordpress default search
- How to perform a heavy and long process in cron jobs?
- Woocommerce extend tax report with custom column
- Is file_get_contents() the only way for plugins reading local files OR does WP_Filesystem_Direct::get_contents() even work?
- Hook into Jetpacks Publicize without using a post type
- How to limit number of number of categories displayed by categories widget
- Is it necessary to do validation again when retrieving data from database?
- Using WordPress PHP code, how to bulk delete only 100 subscribers at a time from thousands of users?
- Checking a WordPress for OWASP top 10 vulnerabilities [closed]
- term_exists() returning NULL on term that exists
- The Correct Way to Use Nonce Field without Settings API
- Run command “composer install” when activating wordpress plugin
- Insert Into Post Not Working For Audio File Using jQuery
- Enqueue a file that’s not js or css
- Import user data using CSV
- What is the replacement for rich_edit_exists()?
- Disable Auto-Expanding Menu in WordPress Admin Menus
- How to submit/upload data to database and in specific folder?
- OOP plugin not working
- why does get_option( ‘home’ ) not work while using in plugin [closed]
- Undefined is_user_logged_in() error with Plugin Query code
- Plugin Options not saving options and doesn’t work
- JQuery Slider – Similar to www.internetmarketinginc.com [closed]
- post content and shortcode content displaying out of order
- Development plugin to view and manage scheduled wordpress cron jobs?
- WordPress video js error this.mediaElement.play is not a function
- Custom Icon for Plugin
- Getting Post ID at “stylesheet” and “template” hooks
- How to store sensitive user data (passwords)
- How can we upload file to root directory of wordpress
- Adding External Gmap JS to WordPress
- First page download plugin
- How to avoid conflict if a plugin already have included open library?
- WordPress OOP get current user question?
- Override WooCommerce files from plugin
- How to make sure wordpress and woocommerce plugins work on all configurations
- WordPress Dropdown image select
- Unable to link CSS file
- post_results filter confused by pagination in sidebar and main section
- Best place to keep files that are called by cron jobs?
- How do I call the dashboard’s sortable javascript in a plugin page?
- Settings API with arrays example
- Help interpreting @wordpress/create-block-tutorial-template usage error
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- React Plugin Settings Page Localization
- Is it within WordPress guidelines to update another plugin’s database fields from my own plugin? [closed]
- Block Development: hamburger module throwing error in save function
- How can I chanage the user for the composer container in wp-env?
- Adding a navigation with wp_nav_menu() to a custom block in the site editor