Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created April 3, 2013 21:28
Show Gist options
  • Save claudiosanches/5305514 to your computer and use it in GitHub Desktop.
Save claudiosanches/5305514 to your computer and use it in GitHub Desktop.
WordPress - Custom comment_form fields
<?php
/**
* Custom comment_form fields
*
* @param array $fields Default form fields
*
* @return array New Form fields
*/
function custom_comment_form_field( $fields ) {
$commenter = wp_get_current_commenter();
$req = get_option( 'require_name_email' );
$aria_req = ( $req ? " aria-required='true'" : '' );
$fields['email'] = '<p class="comment-form-email"><label for="email">' . __( 'Email', 'odin' ) . ' ' . ( $req ? '<span class="required">*</span>' : '' ) . '</label><input id="email" name="email" type="email" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>';
return $fields;
}
add_filter( 'comment_form_default_fields', 'custom_comment_form_field' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment