Last active
August 25, 2017 06:05
-
-
Save luiseduardobraschi/3843940f97c8cc130d8f39f13a4d9c55 to your computer and use it in GitHub Desktop.
Since WordPress uses difrerent templates for both logged and not logged-in users, I ended up having to use some other hooks other than the default filter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function alter_comment_form_fields($fields){ | |
$commenter = wp_get_current_commenter(); | |
$fields['author'] = '<p class="comment-form-input comment-form-author"><label for="author">' . __( 'This is a fancy label', 'your-text-domain' ) . '</label><input id="author" required name="author" type="text" placeholder="Seu nome" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" aria-required="true" /></p>'; | |
return $fields; | |
} | |
function logged_in_fields() { | |
echo implode('', alter_comment_form_fields(array())); | |
} | |
add_filter('comment_form_default_fields','alter_comment_form_fields'); | |
add_action( 'comment_form_logged_in_after', 'logged_in_fields' ); | |
add_action( 'comment_form_after_fields', 'logged_in_fields' ); // this one will do the same thing as the filter comment_form_default_fields; chose one |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment