Skip to content

Instantly share code, notes, and snippets.

@AlphaBlossom
Last active August 29, 2015 14: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 AlphaBlossom/f5fbec9b82fbfe5fd3ba to your computer and use it in GitHub Desktop.
Save AlphaBlossom/f5fbec9b82fbfe5fd3ba to your computer and use it in GitHub Desktop.
Remove Email and URL Fields from WordPress comments form
<?php
//* Do NOT include the opening php tag
/**********************************
*
* Filter Comments Form
* Remove Email and URL Fields
*
* @author AlphaBlossom / Tony Eppright
* @link http://www.alphablossom.com
*
************************************/
/*
* Remove both Email and URL fields
*
*/
add_filter( 'comment_form_default_fields', 'youruniqueprefix_remove_comments_form_url_field' );
function youruniqueprefix_remove_comments_form_url_field( $fields ) {
if( isset( $fields['email'] ) ) {
unset( $fields['email'] );
}
if( isset( $fields['url'] ) ) {
unset( $fields['url'] );
}
return $fields;
}
/*
* Remove Email field
*
*/
add_filter( 'comment_form_default_fields', 'youruniqueprefix_remove_comments_form_url_field' );
function youruniqueprefix_remove_comments_form_url_field( $fields ) {
if( isset( $fields['email'] ) )
unset( $fields['email'] );
return $fields;
}
/*
* Remove URL field
*
*/
add_filter( 'comment_form_default_fields', 'youruniqueprefix_remove_comments_form_url_field' );
function youruniqueprefix_remove_comments_form_url_field( $fields ) {
if( isset( $fields['url'] ) )
unset( $fields['url'] );
return $fields;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment