{"id":6263198,"date":"2015-06-24T11:36:01","date_gmt":"2015-06-24T11:36:01","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/retrieving-custom-fields\/"},"modified":"2016-08-30T14:47:23","modified_gmt":"2016-08-30T14:47:23","slug":"retrieving-custom-fields","status":"closed","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/retrieving-custom-fields\/","title":{"rendered":"Retrieving custom fields"},"content":{"rendered":"<p>Hello,<\/p>\n<p>Thank you for a great plug-in, very versatile . However, I have a couple of custom fields in my comment form, for example, &#8216;country&#8217;. How can I get what was entered into this field to display along with my comment?<\/p>\n<p>The meta for this field is being saved using the following code in my functions.php:<\/p>\n<pre><code>if ( ( isset( $_POST[&#039;country&#039;] ) ) &amp;&amp; ( $_POST[&#039;country&#039;] != &#039;&#039;) )\n    $country = wp_filter_nohtml_kses($_POST[&#039;country&#039;]);\n    add_comment_meta( $comment_id, &#039;country&#039;, $country );<\/code><\/pre>\n<p>And i am able to retrieve the fields when I use the standard wp list comments with a callback:<br \/>\n<code>&lt;?php wp_list_comments( &#039;type=comment&amp;callback=tafcomments&#039; ); ?&gt;<\/code><br \/>\nwhich calls back to this function in my functions.php:<\/p>\n<pre><code>function tafcomments($comment, $args, $depth) {\n        $country = get_comment_meta( $comment-&gt;comment_ID, &#039;country&#039;, true );\n        $GLOBALS[&#039;comment&#039;] = $comment;\n        extract($args, EXTR_SKIP);\n        ?&gt;\n        &lt;div class=&quot;commentBox&quot;&gt;\n            &lt;?php comment_text(); ?&gt;\n            &lt;h6&gt;&lt;?php echo $country; ?&gt;&lt;\/h6&gt;\n        &lt;\/div&gt;\n        &lt;?php\n    };<\/code><\/pre>\n<p>But how do i achieve the same result using this plug-in??<\/p>\n<p>https:\/\/wordpress.org\/plugins\/bwp-recent-comments\/<\/p>\n","protected":false},"template":"","class_list":["post-6263198","topic","type-topic","status-closed","hentry","topic-tag-custom-fields"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6263198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/6263198\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=6263198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}