<?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>Ounce of Talent &#187; Gravity Forms Tip</title>
	<atom:link href="http://ounceoftalent.com/category/gravity-forms-tip/feed/" rel="self" type="application/rss+xml" />
	<link>http://ounceoftalent.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 02 May 2012 10:54:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Gravity Forms Tip: Clean Confirmation Redirects</title>
		<link>http://ounceoftalent.com/2010/05/gravity-forms-tip-clean-confirmation-redirects/</link>
		<comments>http://ounceoftalent.com/2010/05/gravity-forms-tip-clean-confirmation-redirects/#comments</comments>
		<pubDate>Tue, 04 May 2010 03:09:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Gravity Forms Tip]]></category>
		<category><![CDATA[gravity forms]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://ounceoftalent.com/?p=227</guid>
		<description><![CDATA[If you&#8217;re familiar with Gravity Forms you might know that when using the confirmation redirect feature either to a page or a URL, you&#8217;ll see a very quick flicker as the form posts back to itself and then redirects you to the specified page or URL. Not a huge deal&#8230; but once you notice it, [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re familiar with Gravity Forms you might know that when using the confirmation redirect feature either to a page or a URL, you&#8217;ll see a very quick flicker as the form posts back to itself and then redirects you to the specified page or URL. Not a huge deal&#8230; but once you notice it, it&#8217;s hard to ignore. If you&#8217;ve never noticed it before&#8230; well, sorry to Shallow Hal* you, but we can make this fat chick beautiful with a surprisingly simple bit of code:</p>
<pre class="brush: php">
add_filter("gform_post_submission", "hide_form", 10, 2);
function hide_form($entry, $form) {
    if($form["confirmation"]["type"] != "message")
        echo '
<style type="text/css"> body { display: none; } </style>

';
}
</pre>
<p>So what are we doing here? Not much. We&#8217;re just using one of Gravity Forms built in filters <strong>gform_post_submission</strong> to call a custom function that we create below called <strong>hide_form</strong>. Whenever I finally understand what those last two parameters do, I&#8217;ll tell you too.</p>
<p>So the filter passes two parameters to the function which are <strong>$entry</strong> and <strong>$form</strong>. The $entry variable is an array of all the values entered into the form and the $form variable is an array of juicy information about the form itself. For our purpose, we only need the $form array. This array contains a property called &#8220;confirmation&#8221; which contains a property called &#8220;type&#8221; which contains a single value which will either be &#8220;message&#8221;, &#8220;page&#8221;, or &#8220;url&#8221;. </p>
<p>Two of these values (&#8220;page&#8221; and &#8220;url&#8221;) mean that the form is going to be redirecting to either a page or you guessed it! A URL! If the form confirmation type is set to &#8220;message&#8221;, however, the form will not be redirecting and so we want to make sure that whatever we&#8217;re going to do for the redirection confirmation types, we do not want to do for the non-redirection confirmation type. This is accomplished with a simple conditional that in reads &#8220;if the confirmation type is not &#8216;message&#8217; then run the following code&#8221;. </p>
<p>That brings us to the handy dandy style declaration that hides the body of the page so the redirect can be processed without any visual interference. That&#8217;s right. No annoying flicker when the form page begins to load and is then redirected to the actual confirmation page. Any questions?</p>
<div class="msg">PS &#8211; Sorry for the lack of a comments section. This site was originally designed as a strictly portfolio site and I&#8217;ve been adding to it since. Drop me a line on my <a href="/contact/">contact form</a> if you&#8217;ve got something to share. <img src='http://ounceoftalent.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </div>
<p><small>* If you haven&#8217;t seen the movie, ignore this reference.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://ounceoftalent.com/2010/05/gravity-forms-tip-clean-confirmation-redirects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

