wordpressでコメントの必須メールアドレス欄を削除する方法

wordpressでコメントの必須メールアドレス欄を削除する方法です。

基本的にはチェックを外して、入力欄を消すだけです。

 

1.まずはメールアドレスのバリデートを外します。

対象ファイル:wp-comments-post.php

↓ここをコメントアウト
if ( get_option('require_name_email') && !$user->ID ) {
	if ( 6 > strlen($comment_author_email) || '' == $comment_author )
		wp_die( __('Error: please fill the required fields (name, email).') );
	elseif ( !is_email($comment_author_email))
		wp_die( __('Error: please enter a valid email address.') );
}
↓以下を記述
if (!$user->ID ) {
    if ('' == $comment_author)
        wp_die( __('Error: please fill the required fields (name).') );
}

2.次にコメントテンプレートのメールアドレスの欄をコメントアウトする
対象ファイル:comment-template.php
↓こんな感じ。
	$fields =  array(
		'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) .
		            '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>',
/*
		'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>',
	);
以上!
これでバッチリ消えているはず。。


コメントを残す