Last active
January 29, 2017 09:26
-
-
Save danielpowney/1f433f0b3ace85ea612bf76d592264d7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* Changes order of comment form fields for anonymous users. Rating form items first, followed | |
* by comment, author, email and url. Note the comment_form_fields filter is only available since | |
* WordPress 4.4 | |
* | |
* @param array $fields | |
* @return array $fields | |
*/ | |
function my_comment_form_fields( $fields ) { | |
$comment = $fields['comment']; | |
unset( $fields['comment'] ); | |
array_push( $fields, $comment ); | |
$author = $fields['author']; | |
unset( $fields['author'] ); | |
array_push( $fields, $author ); | |
$email = $fields['email']; | |
unset( $fields['email'] ); | |
array_push( $fields, $email ); | |
$url = $fields['url']; | |
unset( $fields['url'] ); | |
array_push( $fields, $url ); | |
return $fields; | |
} | |
add_filter( 'comment_form_fields', 'my_comment_form_fields', 100, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment