612-293-8629 HELLO@THEMIGHTYMO.COM

Yesterday I showed you how I added a new textfield to my WordPress comments. Toay I will show you how I displayed that data in both the “comments” panel in the admin as well as the comment listing on the front end.

The solution was to create a filter for the comment text and simply prepend my new data to the normal comment output.

(FYI, “organization” in the code below refers to the textfield we created yesterday.)

function ufmn_add_organization_to_comment_admin ( $comment_text ) {
	$commenter_organization = get_comment_meta( get_comment_ID(), "organization", true);
	if ( $commenter_organization ) {
		$ufmn_organization_text = '<div class="organization-text"><strong>Organization: ' . $commenter_organization . '</strong></div><!-- .organization-text -->';
		return $ufmn_organization_text . $comment_text;
	} else {
		return $comment_text;
	}
}
 
add_filter( 'comment_text', 'ufmn_add_organization_to_comment_admin' );

Many thanks to WPTavern for the code above!

PHONE, EMAIL, TEXT

We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.

LOCATIONS

PAYMENTS ACCEPTED

Call Now

Enroll in Our Free Beginner WordPress Class - delivered to your Email Inbox!

Become a WordPress superstar for FREE in only minutes a day!  Our free Beginner WordPress Email Class will be delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!