Skip to content

Instantly share code, notes, and snippets.

@WordPress-Handbuch
Last active April 11, 2019 07:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WordPress-Handbuch/00473433c2f4a2c9b5de40b74ec5096a to your computer and use it in GitHub Desktop.
Save WordPress-Handbuch/00473433c2f4a2c9b5de40b74ec5096a to your computer and use it in GitHub Desktop.
Anti spam measure: Remove all links in WordPress comments when the comment form is being submitted, using a filter hook
function wh_remove_comment_links( $content ) {
global $allowedtags;
$tags = $allowedtags;
unset( $tags['a'] );
$content = addslashes( wp_kses( stripslashes( $content ), $tags ) );
return $content;
}
add_filter( 'pre_comment_content', 'wh_remove_comment_links' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment