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?
- what is __return_false in filters
- How to filter users on admin users page by custom meta field?
- Passing Additional Parameters to add_filter Callable
- How can I add an Author filter to the Media Library?
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Change upload directory on custom plugin page
- Loading template files from a subfolder in my theme?
- How to use the_excerpt in a filter hook?
- Add wrapper to only youtube videos via embed_oembed_html filter function
- Hook into admin post list page
- Add post/page ID to inserted links within the_content
- How to exclude/filter a tag from get_the_tag_list()
- Shortcodes not resolved in AJAX call response
- Possible to filter the posts or categories that XML-RPC users see in their mobile application?
- Ajax, filters and shortcodes
- Filter the blog’s title without using global variables
- wp_link_pages output appears twice
- Multiple Ajax Data Action
- user_has_cap filter allows edit but will not allow save
- How do I pass the value from a foreach loop to an add_filter function? [closed]
- Can you use add_filter() inside other function?
- is there a specific place where add_filter must be placed?
- How do I replace a render_callback function for a block?
- add_filter() function misunderstanding
- check if FILTER(“the_content”) is being executed in `the_post()`
- Change Password Strength Indicator names?
- Is there a wildcard/catchall filter hook?
- Filter my args by the post 1st letter
- Limit RSS feed to previous calendar month
- How to contribute to WordPress Core using Tortoise SVN?
- Adding Filter to Homepage only
- the_excerpt filter with an empty excerpt
- Is this the proper way of switching the “Edit My Profile” link with my BuddyPress “Extended Profile” link?
- Does auto_update_plugin Filter Work When Put In Theme’s functions.php File
- Remove CSS & JS files from WordPress Main Page For Increase Pagespeed?
- In need of a content replace filter for posts in a specific wordpress category
- html tags in gettext hook get escaped
- How to remove action with slashes and arrows?
- Inline Styles on all native blocks
- How to filter post content and force every link () made in blocks to return urldecode() with readable value?
- Set default terms for new posts / CPTs
- Get .subsubsub count of post per status queried using pre_get_posts
- Adaptive product filters for WooCommerce
- Link to Shop-Filter with .current-menu-item
- Plugin options, presets and filters : can you help me improve my workflow?
- Remove posts inside pre_get_posts using a custom query
- Remove / Hide Attachment Display Settings in Add Media popup / dialog
- how to customize rss feed tags using hooks?
- Wrapping my head around add_filter
- Is it possible to apply filter to meta key value when querying posts?
- How to add_filter to an OOP based apply_filter(‘foo::bar’, $a);
- apply_filters with multiple args and multiple add_filter
- Help with filter for wp_notify_moderator()
- Should I remove_filter in order to replace a filter?
- Change custom post type GUID in RSS
- How can I specify the post status of an untrashed post?
- Conflict calling an add_filter() twice
- Filter for author list in gutenberg core editor
- Add something after a filter
- Rewrite rule and display of post
- Passing variable from child theme function to parent theme filter
- Add filter unless it is being called under specific function
- paginate_links() Change the order of links
- Filter / add_action to upgrade.php page
- Add Filter – Pass Variable (PHP < 5.3)
- Why does admin_body_class not work?
- Problem width wp_insert_post_data and Gutenberg block editor
- style_loader_tag not changing stylesheet to preload
- add_filter doesn’t return false?
- How to track a particular page in order to address the loading speed issue
- Changing title using filter not working with argument
- Archive Widget – Count only parent posts
- how to overwrite next_post_link
- Cutting off excerpt with first sentence
- Change URLs in default WordPress slider to relative from absolute
- Print url to default featured image
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Change add_filter based on Ajax
- What action/filter can be used for modifying the page to be rendered?
- Adding user filter – Not updating data in URL
- How to check which submission button was clicked?
- How to add more than one custom metadata as filter on the post list page?
- filter wptexturize doesn’t work on old posts titles
- remove_action conditionally for Custom Post Type – not working
- wp_get_attachment_link filter not working
- How would I remove an inline googleAPI font script in the the parent theme header.php?
- Add Default WordPress Formatting To Data From External SQL Tables?
- Getting entry ID from frm_email_message filter in formidable
- Is there a hook or filter that adds a button to the left of the search box?
- filter a list by gender
- Can you call a filter hook by “add_action”?
- Why isn’t this add_filter function working as expected?