Well the best way is to use a antispam plugin like Aksimet. Other captcha plugins can be helpful too, you just have to look for the captcha
keyword in wordpress repository.
If you want to do this manually, I can give you a hint. First of all, you need to know which action hook you want. I couldn’t find an action that fires before the comment insertion, but comment_post runs after that.
Then you need to detect if your comment body contains a url, this SO question can be helpful with that. You can delete a comment with wp_delete_comment function.
Related Posts:
- Filter out other users comments. Visualize only own comments and editor role users’ comments
- WordPress comment processing . Default unapproved comments detection before posting
- remove empty paragraphs from the_content?
- Set JPEG compression for specific custom image sizes
- Remove Comments Metabox but still allow comments
- Removing default image size list in Media Box
- How to restrict actions and filters “properly” by conditions
- syntax for remove_filter in parent theme with class
- change the comment time output to: X time ago instead of actual date and time
- How to get comments with mixed status using get_comments?
- How to prevent deleting of comments when deleting a post
- Override parent theme function that is not hooked or in the functions.php file
- Display the number of user comments
- Removing title from page
- Hide some items from Screen options in dashboard for products
- Replace Archive Widget Link Text
- Exclude Empty Child Categories in Menu
- How to make unique add_filter to the_content of specific page template files – so each template gets its own addition
- Best way to programatically add “rel” attributes to page and post images
- Comments to only be seen by their author
- add_filter priority problem
- Limit filter upgrader_post_install to a single plugin
- How to update feed only 2-3 times a week (for Feedburner email)?
- Clean-up script tags
- Remove function or filter
- Super simple shortcode not working
- How to filter out shortcode when displaying the_excerpt() in the loop?
- Adding multiple taxonomy filters to functions.php
- Last updated date function
- Change the HTML of the comment form that is generating somewhere from the core WordPress
- How to set default archive image without overriding first attached image? [closed]
- Only let plugin add actions to wp_head & wp_footer on single posts
- How to make custom column Admin>Users sortable?
- Get Current Post ID in functions php, meta query filter
- Output and filter data from a XML url
- What did I do wrong in my functions code, that will not change the “Get New Password” text to “Send It”?
- How to filter $content in shortcode function
- Filtering out the #more anchor link that gets produced by
- Getting comment count per post not working
- Wp admin – Set default value to 999 in comments
- Add Element as a Filter to the_content
- How can I add a filter for specific categories on functions.php?
- How to add custom JavaScript in functions?
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- Can’t properly set the_title add_filter to show short_URL
- Filter an WordPress Function in (general-template.php)
- Redefine function arguments before rendering
- Filter nav menu items HTML tags and wrap inner text with span
- How can I add a class to a nav li depending on URL?
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- Filter to wp_list_authors
- How to add custom li item to wordpress menu
- Add Adsense code between job listings – wp job manager plugin
- Problem with images URL after filter applying
- remove_action not working, even after changing priority [duplicate]
- remove/hide wp-editor
- Function to replace comment’s accented characters before posting
- Replace header image on all other pages but home – URL issue
- Add a class to post if it has been recently updated
- search form leads to 404
- how to add_filter to non hook function
- How to display an image before title text in menu items
- How do I change where “You must be logged in to comment” directs users?
- How do I make the comment disappear after deleting from the database?
- Overwrite text in a complicated filter hook
- Save_post – Warning: Cannot modify header information
- custom error message for empty username and password using authenticate filter not working
- Add #primary at the end of navlink permalinks on single posts
- remove_filter function to unhook twentysixteen parent theme function
- only update titles of single posts
- OOP Switch statement with array as parameter
- Remove nofollow from internal comment links via functions.php
- Appending „read more” to the excerpt conditionally
- How to add class dynamically from templates
- function replace_text for entire page
- Comment function for page
- ACF Filter return value
- Graphic before title – Specific Category
- How to make an If Else on Excerpt Filter
- Why might wptexturize have become re-enabled?
- Newest comments first not working
- Regex works in regexr, but not if I filter content [closed]
- get_comments not working properly after WordPress v4.4 update
- Retrieve a custom form field modified by a filter
- functions.php filters not applied in AJAX call
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- Increase Comment Author Gravatar Size On WordPress Default Comment Function
- Can’t change excerpt length and more tag
- Force resize for all video content
- Way of getting queried loop before the query with a filter hook?
- How to remove “login to reply” from individual comments [duplicate]
- Trying to get this function to show below the content
- Getting full code of wp_list_comments instead of replacing it
- User’s Comments Number: Storing it in a meta field for different uses
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- How can I modify or filter this variable in an existing class? (Mai Theme)
- Add functionality to block comment authors in the Comment edit pag