A fresh mix of code snippets and tutorials

WordPress: Display all comment fields when user is logged in

By default WordPress hides the Author/Name, Email, and URL fields on comment forms when the user is logged in. This is because WordPress automatically gets the related information directly from the user profile. But what if you need to do some testing or troubleshooting and want to display all the fields? Here is a plug-&-play snippet that makes it happen:

// Display all comment form fields when user is logged in
// @ 
function shapeSpace_show_all_comment_fields($fields) {
	if (is_user_logged_in()) {
		$comment_field_keys = array_diff(array_keys($fields), array('comment'));
		$first_field = reset($comment_field_keys);
		$last_field  = end($comment_field_keys);
		// unset($fields['cookies']);
		foreach ($fields as $name => $field) {
			if ('comment' === $name) {
				echo apply_filters('comment_form_field_comment', $field);
				// echo $args['comment_notes_after'];
			} else {
				if ($first_field === $name) {
				echo apply_filters("comment_form_field_{$name}", $field) . "\n";
				if ($last_field === $name) {
		return array();
	return $fields;
add_filter('comment_form_fields', 'shapeSpace_show_all_comment_fields');

This isn’t the cleanest way of doing things, but it certainly works well enough (and with no PHP warnings or errors). Your mileage may vary. Not recommended for production sites.

Note: I am not the author of this snippet, if you know the original source please let me know. Thanks!

Learn more

Digging Into WordPressWordPress Themes In DepthWizard’s SQL Recipes for WordPress