PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 26, 2022

[FIXED] How to remove "email" and "url" fields in WordPress comment form?

 August 26, 2022     comments, php, wordpress     No comments   

Issue

How can I remove Email and Website fields in "Leave a Reply" form in WordPress?

Like this : [URL removed - malware link]

I only want to see Name (leave blank for Anonymous) and the comment field.

I'm using WordPress 3.2.1 and using the default WordPress comments.

public_html/wp-includes/comment.php

and

public_html/wp-includes/comment-template.php

I've removed this code from comment-template.php:

'email'  => '<p class="comment-form-email"><label for="email">' . __( 'Email' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
                    '<input id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>',
        'url'    => '<p class="comment-form-url"><label for="url">' . __( 'Website' ) . '</label>' .
                    '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>',

But this is not working. I think removing only this code is not enough!

Now what do I do?


Solution

  1. Create this plugin using notepad application from windows and remember to save the file with a .php extension Eg : removeurl.php

  2. Copy and paste the below code in the file created in step 1

    <?php
    /*
    Plugin Name: Remove Website Field
    Description: Removes the website field from the comments form
    */
    add_filter('comment_form_default_fields', 'url_filtered');
    function url_filtered($fields)
    {
      if(isset($fields['url']))
       unset($fields['url']);
      return $fields;
    }
    
    ?>
    

Plugin Credit goes to TechHacking.com

  1. Save your changes and upload it via FTP or through your web hosts file manager to the /wp-content/plugins/ directory

  2. Go plugins menu option in your wordpress admin area and activate the plugin. With this simple hack you will be to remove the website field from the comment form.

If in any case the plugin does not work or the function does not work you can also use this method, I used this method in lot of my customization work and its proved to be very effect without any problem. To do so open your theme main css (Style Sheet) copy and paste below code

#commentform #url, #commentform #url +label {display:none;}

source : http://www.shariff.org/remove-website-field-comment-form.html



Answered By - King Tohi
Answer Checked By - Cary Denson (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing