• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » Snippets » WordPress Snippets » Remove Website and Email Fields from WordPress Comment form

Remove Website and Email Fields from WordPress Comment form

Posted on July 10, 2012 by Renji | Short URL: http://sumtips.com/?p=7173

Drop this code into your theme’s functions.php file to remove both ‘website’ and ‘email’ field from WordPress’ comment form:

function remove_website_email_field($fields)
{
 $fields = array( $fields['author']); //add $fields['email'] for only website field
 return $fields;
}
add_filter( 'comment_form_default_fields', remove_website_email_field );

Removing ‘email’ field will only work if you have “Comment author must fill out name and e-mail” option disabled on Discussion Settings page.

Or, you can also create a plugin to do this. Create a new file with .PHP extension in wp-content/plugins/ with this code:

<?php
function remove_website_email_field( $fields ){
  if(isset($fields['url'], $fields['email'])) //remove $fields['email'] for only website field
    unset($fields['url'], $fields['email']); //remove $fields['email'] for only website field
  return $fields;
}

add_filter( 'comment_form_default_fields', 'remove_website_email_field' );
?>

Plugin would be handy if you are using a theme that receives regular updates. This also gives you the option of easily disabling the feature from your dashboard.


Tweet

Related posts:

  • Add, Delete and Edit Custom Fields in WordPress
  • Disable WordPress Comment Form User Details Cookie
  • Prevent Copy, Cut and Paste into HTML Input Text Fields
  • Schedule Google Analytics to Email Website Performance Report
  • Remove and Reorder Menu/Submenu Links in WordPress Dashboard
Categories: WordPress Snippets
Disable WordPress Comment Form User Details Cookie
Add Custom Media Type Filters in WordPress Media Library

One Response to “Remove Website and Email Fields from WordPress Comment form”

  1. anton says:
    July 18, 2012 at 9:19 PM

    How to remove website form only

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • Wrap Mouse Pointer Around The Screen
    • Times Square Image Created Over 4 Years with 750,000 Layers
    • Add/Remove Context Menu Commands on XP
    • Customize WordPress HTML Editor With Custom Quicktag Buttons
    • Scratchpad – An Offline Notepad App for Chrome with Docs Sync
    • Customize Headers And Footers While Printing Webpages
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy