<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Christian Schenk&#187; fields</title>
	<atom:link href="http://www.christianschenk.org/blog/tag/fields/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christianschenk.org</link>
	<description>Writing about my experiences with technology and all different kinds of projects and experiments</description>
	<lastBuildDate>Sun, 04 Dec 2011 23:43:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>WordPress: Add notes to the comment form</title>
		<link>http://www.christianschenk.org/blog/wordpress-add-notes-comment-form/</link>
		<comments>http://www.christianschenk.org/blog/wordpress-add-notes-comment-form/#comments</comments>
		<pubDate>Wed, 16 Dec 2009 07:10:19 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[comment]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[fields]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/?p=727</guid>
		<description><![CDATA[Most themes use the comment_form action which can be used to add arbitrary things to the comment form with a plugin. This post presents a simple plugin that uses custom fields to add special notes to this section. You can download the plugin here, unzip it, upload it to your wp-content/plugins directory and activate it. [...]]]></description>
			<content:encoded><![CDATA[<p>Most themes use the <code>comment_form</code> action which can be used to add arbitrary things to the comment form with a plugin. This post presents a simple plugin that uses custom fields to add special notes to this section.</p>
<p>You can download the plugin <a href="http://data.christianschenk.org/wordpress-add-notes-comment-form/comment-form-notes.php.zip">here</a>, unzip it, upload it to your <code>wp-content/plugins</code> directory and activate it.</p>
<p><span id="more-727"></span></p>
<h2>How to</h2>
<p>Using this plugin is super simple: just add a custom field named <code>cnote</code> to a post/page and enter the content that should appear next to the comment form into its value field.</p>
<p>Here&#8217;s an example:</p>
<p><img src="/wp-content/uploads/cnote_cf.png" alt="Custom Field" title="cnote_cf" width="473" height="70" class="size-full wp-image-728" /></p>
<p>When WordPress renders the page, the plugin will pick up the content of your custom field and display its content next to your comment form. It may look like so:</p>
<p><img src="/wp-content/uploads/cnote_result.png" alt="Result" title="cnote_result" width="254" height="87" class="size-full wp-image-729" /></p>
<p>The plugin expects that you enter some text, so it inserts your content into a <code>p</code> element. This element has got a class <code>cnote</code> helping you to style the notes with CSS.</p>
<h2>The code</h2>
<p>In case you&#8217;re developer and want to know more about the code just have a look at the plugin, it&#8217;s really straight forward. What it does is this: look out for a custom field named <em>cnote</em>, if it&#8217;s present we&#8217;ll output it&#8217;s contents otherwise nothing happens.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$note</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post_id</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'cnote'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$note</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$note</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span></pre></div></div>

<p>This gets registered with the <code>comment_form</code> action and will be executed once the theme calls this action.</p>
<h2>Conclusion</h2>
<p>Using custom fields we can add hints to comment forms on a post/page basis. This technique may be really helpful in case you would like to tell the user something special just before he fills out the comment form.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/wordpress-add-notes-comment-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

