<?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>almost daniel &#187; FormPress</title>
	<atom:link href="http://almostdaniel.com/categories/formpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://almostdaniel.com</link>
	<description>i am a coder, an array explode(r). but here is where i write.</description>
	<lastBuildDate>Tue, 16 Mar 2010 21:35:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>I&#8217;m a real boy, er, plugin!</title>
		<link>http://almostdaniel.com/2008/04/06/im-a-real-boy-er-plugin/</link>
		<comments>http://almostdaniel.com/2008/04/06/im-a-real-boy-er-plugin/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 03:07:05 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[FormPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[wordpress.org]]></category>

		<guid isPermaLink="false">http://almostdaniel.com/?p=17</guid>
		<description><![CDATA[It&#8217;s official. FormPress is now live at wordpress.org.

]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s official. FormPress is now live at <a href="http://wordpress.org/extend/plugins/formpress/">wordpress.org</a>.<br />
<a href='http://almostdaniel.com/wp-content/uploads/2008/04/wordpress-formpress.png'><img src="http://almostdaniel.com/wp-content/uploads/2008/04/wordpress-formpress-thumb.png" alt="Thumbnail image of the WordPress.org Plugin Directory" title="wordpress-formpress-thumb"  class="alignnone wp-image-18" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://almostdaniel.com/2008/04/06/im-a-real-boy-er-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>FormPress 0.2 released</title>
		<link>http://almostdaniel.com/2008/04/03/formpress-02-released/</link>
		<comments>http://almostdaniel.com/2008/04/03/formpress-02-released/#comments</comments>
		<pubDate>Thu, 03 Apr 2008 20:31:38 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[FormPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://almostdaniel.com/2008/04/03/formpress-02-released/</guid>
		<description><![CDATA[The second update for the beta of FormPress has been released. This version introduces a new &#8220;Required Fields&#8221; feature as well as many maintenance updates.
]]></description>
			<content:encoded><![CDATA[<p>The second update for the beta of <a href="http://almostdaniel.com/formpress/">FormPress</a> has been released. This version introduces a new &#8220;Required Fields&#8221; feature as well as <a href="http://almostdaniel.com/formpress/changelog/">many maintenance updates</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://almostdaniel.com/2008/04/03/formpress-02-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Turning WordPress into a fancy form processor</title>
		<link>http://almostdaniel.com/2007/11/21/turning-wordpress-into-a-fancy-form-processor/</link>
		<comments>http://almostdaniel.com/2007/11/21/turning-wordpress-into-a-fancy-form-processor/#comments</comments>
		<pubDate>Wed, 21 Nov 2007 16:33:22 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[FormPress]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://almostdaniel.com/2007/11/21/turning-wordpress-into-a-fancy-form-processor/</guid>
		<description><![CDATA[Yes, I know. Five+ years of development. An approach to open-source content management that is at the same time refreshing and inspired. One of the top blogging tools in the world.
And now, WordPress processes my forms for me.


Preempting Genius
The WordPress Plugin API provides hooks into the execution of its code via Actions. As someone views [...]]]></description>
			<content:encoded><![CDATA[<p>Yes, I know. Five+ years of development. An approach to open-source content management that is at the same time refreshing and inspired. One of the top blogging tools in the world.</p>
<p>And now, <a href="http://wordpress.org/">WordPress</a> processes my forms for me.<br />
<span id="more-6"></span></p>
<hr />
<h3>Preempting Genius</h3>
<p>The <a href="http://codex.wordpress.org/Plugin_API">WordPress Plugin API</a> provides hooks into the execution of its code via <a href="http://codex.wordpress.org/Plugin_API#Actions">Actions</a>. As someone views a page on your site, a chain of events is triggered until the requested page is displayed. All along this chain, WordPress notifies itself that it is completing certain Actions.</p>
<p>Plugin developers can use the fact that WordPress has just triggered one of its core functions and execute one of the plugin functions as well. In this way, your plugin can insinuate itself quite deeply inside the main WordPress package.</p>
<p>The earliest Action hook that I could find is named <a href="http://codex.wordpress.org/Plugin_API/Action_Reference#Advanced_Actions">init</a>.  The <a href="http://codex.wordpress.org/">WordPress Codex</a> describes this Action:</p>
<blockquote><p> Runs after WordPress has finished loading but before any headers are sent. Useful for intercepting $_GET or $_POST triggers.</p></blockquote>
<p>Translation: Runs after WordPress loads its function environment but before it has displayed anything in the user’s browser. Use our software for your own nefarious goals.</p>
<p>Amazing. They <em>suggest </em>that you use this to turn their software into something else entirely. With a minimum of 8 lines of code, I subverted my favorite open-source software into a simple forms processor that had the power (and data set) of my entire WordPress tool behind it.</p>
<h3>The Method</h3>
<p>Using WordPress Actions is basically a two step process:</p>
<ol>
<li>Write a PHP function that you want to be triggered at some point in the WordPress  execution chain.</li>
<li>Use the <strong>add_action()</strong> function to inform WordPress of a) the core function you want to piggy-back on, and b) the name of the function you wrote in step 1.</li>
</ol>
<h4>Write the Function</h4>
<p>I wanted people to be able to use my WordPress as the action URL in HTML forms. Something like:</p>
<pre>&lt;form action="http://almostdaniel.com/?form_submit=123" method="post"&gt;</pre>
<p>I needed a function that could check for a particular attribute each time my site is accessed, and if the attribute is there, preempt everything else WordPress does (such as loading my actual site) and instead process the form that is (hopefully) being submitted.</p>
<pre>function form_submit() {
 $form_ID = $_REQUEST['form_submit'];
 if ( !empty($form_ID) ) {
  form_do_submit($form_ID, $_REQUEST);
  exit;
 }
}</pre>
<p><em>Note: I&#8217;m only checking to see if some value got passed in “form_submit”</em><em>. A well-written function would validate the information and only process the form if useful information was being passed. I could even go so far as to make sure that the origin of the submission is allowed. But that is for another post.</em></p>
<p>The <strong>form_submit()</strong> function checks to see if the query item “form_submit” was passed to WordPress. In this case, the value of the query item is the form ID number that I will use in processing. If the query item “form_submit” was submitted, I execute a the function <strong>form_do_submit()</strong> (I put it in its own function just for cleanliness of code) that actually processes the submitted <em>$_REQUEST</em> object (i.e., the contents of the form the user just submitted).</p>
<p>And here is the beautiful part: While I am processing the submitted form, I can use any WordPress function I want. I can store and retrieve data from the WordPress database. This proves quite useful.</p>
<h4>Let WordPress in on the Secret</h4>
<p>Now, to tell WordPress when I want it to execute this function, I use the <strong>add_action()</strong> function to my plugin’s main execution space. This ensures that I will always trigger my query check each time my plugin is loaded no matter what.</p>
<pre>add_action('init', 'form_submit', 1);</pre>
<p>As soon as WordPress loads its environment, my <strong>form_submit()</strong> function is executed. The ‘1’ just tells WordPress to execute my function as early as possible (a ‘10‘ would have told WordPress to execute my function as late as possible).</p>
<h4>Jump Ship</h4>
<p>Why does WordPress run my function and not load my website? The handy <strong>exit</strong> command I put in my <strong>form_submit()</strong> function. As soon as I&#8217;ve processed my form, I just tell WordPress to take a coffee break. And we&#8217;re done!</p>
<h3>The Code</h3>
<p>Here is the code in my plugin’s main file:</p>
<pre>function form_submit() {
 $form_ID = $_REQUEST['form_submit'];
 if ( !empty($form_ID) ) {
  form_do_submit($form_ID, $_REQUEST);
  exit;
 }
}

add_action('init', 'form_submit', 1);</pre>
]]></content:encoded>
			<wfw:commentRss>http://almostdaniel.com/2007/11/21/turning-wordpress-into-a-fancy-form-processor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
