Skip to content

Instantly share code, notes, and snippets.

@danielpowney
Last active January 29, 2017 09:26
Show Gist options
  • Save danielpowney/1f433f0b3ace85ea612bf76d592264d7 to your computer and use it in GitHub Desktop.
Save danielpowney/1f433f0b3ace85ea612bf76d592264d7 to your computer and use it in GitHub Desktop.
<?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