You aren’t filtering correctly. Firstly, you aren’t passing variables to the function, so your function has no way of knowing what $comment_author is, etc. If you had debug mode enabled you’d probably get errors about undefined variables. Secondly, you need to return a value.
Untested, but seems like it ought to work:
add_filter('pre_comment_approved', 'custom_blacklist', 10, 2 );
function custom_blacklist( $approved, $commentdata ) {
extract($commentdata, EXTR_SKIP);
if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
$approved = 'trash';
return $approved;
}
Related Posts:
- How to remove X-Frame-Options: SAMEORIGIN” from WordPress?
- Clarification on filters and hooks
- How to modify core when there is no hook?
- Filters/Bulk Actions return wrong URL in admin dashboard
- Changing WordPress core without hacking core
- Override has_post_thumbnail function
- Removing a line from a WP core function (comment_template.php) – filter or other technique?
- remove_function method removing next priority action too while removing current priority
- Add custom options to the wplink dialog
- Sanitize and data validation with apply_filters() function
- How many filter/action hooks are healthy?
- Filter specific shortcode output?
- Insert new element to array with add_filter
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- How do I use the ‘http_request_host_is_external’ filter
- get_option() filtering and getting out of recursion
- Get excerpt from $post->post_content
- How can I add information underneath the user’s name on the users.php page?
- Is calling function_exists() faster or slower that apply_filters()
- AJAX filter posts on click based on category
- How can I filter Microsoft Word gunk from pasted content?
- How to disable all WordPress emails modularly and programatically?
- How do I know if author field was changed on post save?
- Allow Profile HTML for select users
- WordPress 3.5+ upload tool filter
- Search with filters and title
- Some questions regarding filter
- Use content custom filter for all shortcodes
- Filter all html output
- Which hook is fired when inserting media into a post
- How do I filter get_the_excerpt() but keep all of its functionality intact?
- Remove tags from the kses filter
- Overwrite default WordPress wording
- How to add a class to Tag cloud widget link?
- How to get all the predefined do_action() calls from an active theme
- Is there a get_post(s) filter that can alter/replace the output completely?
- WooCommerce Variable Product Price – Where is “From” text generated from?
- Using ‘posts_where’ on a query with a custom field
- Wrap h1-h6 in a div
- How to add numeric slug for child page in WordPress 5.9?
- add_filter does not work as expected
- Custom Login Errors and variables I can use
- ‘the_content’ filter removing html tags from post content
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- I can not include page to wordpress function add_filter, the_content
- Filter to shorten column content on edit-tags.php
- Formatting get_post content doesn’t allow JS content to function properly
- Proper after_setup_theme and wp_head cleanup
- how to use force_filtered_html_on_import in add_filter?
- Filter Hook callback error, is it due to using $this inside a filter or something else?
- Safely editing core files
- Run posts_where and posts_join only on the main query
- Disadvantage of using filters & hooks multiple times
- How To Override A WooCommerce AJAX Function
- run shortcode in excerpt of single custom post type
- Get The Caller (Plugin / Theme / Core) For All actions & Hook in WordPress
- How to trim white space in search terms?
- Changing the argument of a function
- Add/remove CRON action depending on variable
- Stripping URLs & Email from post submissions
- comment_for() Custom fields not visible when user is logged in
- I’ve set up an extra field for all the available widgets. How do I show it’s value in the front-end?
- Access post ID in “content_save_pre”
- Remove pretty photo style and script if not exist!
- custom gallery filter with image caption as link title?
- Gallery stripped from excerpt of post
- BuddyPress – A hook available to hide custom born date on public profile view?
- The gettext hook doesnt work on text with links
- auth_redirect() doesn’t send users to the page where they orginally tried to acces
- the_content getting current page content instead specified ID
- Custom sort orderby question
- “The editor has encountered an unexpected error” After add defer tag to java script
- Override wordpress audio playlist
- Hook to add content after date in post?
- Create different flavours of excerpt
- Search with filters
- Add Index to Item in WordPress Gallery
- How to add_filter only when content is not empty?
- filter out
- Filter template text
- WP Dashboard -> Posts-> Filter > BUG!
- How to remove the post pagination (Next page tag) depending on type of traffic source: from utm_campain or non-utm_campain
- add_filter not working inside if function
- How do I disable the warning “The backup of this post in your browser is different from the version below”?
- Change url to posts if they have custom tax only
- How to get to the date of the uploaded file
- How to filter posts in admin by before date or by post status ‘future’?
- Can’t get content of all (19) posts – Incomplete Chunked Encoding
- Customize register form page with add_action or apply_filter
- WooCommerce comments_template Filter Not Firing
- Woocommerce: Only one review per verified buyer [closed]
- Footnotes with dynamic title attributes?
- Can you call a filter hook by “add_action”?
- Hooking/Filtering theme name to add theme directory
- How to use filter in this situation, can not modify the structure using filter
- add_filter – create_function pb in PHP8
- Woocommerce price filter widget always shows max price of most expensive product in the whole shop
- Filter hook for the action of listing users