Gravity Forms – enable automatic entry deletion

How can I prevent Gravity Forms from saving entries?

This is a question that comes up every so often. The answer is, you can't. Gravity Forms needs to save the entry for those values to be available for use in notifications, confirmations and to send them to third-party services.

What you can do however is delete the entry at the end of the submission process. The following code snippet will add a checkbox to the Form Settings page, check the box and the entry will automatically be deleted.

Delete Entries

This snippet requires the latest version of Gravity Forms be installed, Gravity Forms 1.8.6 was released earlier today so go and update. You can then add the following code snippet to your theme functions.php file or custom functionality plugin, you don't need the <?php from line 1.

Converting the Gravity Forms next, previous and submit inputs to buttons

Last time I covered Removing the Gravity Forms submit button, this time I'm going to show you how you can use the same gform_submit_button hook along with two new hooks, gform_next_button and gform_previous_button, to change the <input> element to a <button> element with an addtional <span> element to contain the label.

Let's start by taking a look at what the HTML for the average next, previous and submit buttons look like:

<input type='button' id='gform_next_button_245_1' class='button gform_next_button' value='Next' tabindex='2' onclick='jQuery("#gform_target_page_number_245").val("2"); jQuery("#gform_245").trigger("submit",[true]); '/>
<input type='button' id='gform_previous_button_245_4' class='button gform_previous_button' value='Previous' tabindex='5' onclick='jQuery("#gform_target_page_number_245").val("1"); jQuery("#gform_245").trigger("submit",[true]); '/>
<input type='submit' id='gform_submit_button_245' class='button gform_button' value='Submit' tabindex='8' onclick='if(window["gf_submitting_245"]){return false;}  if( !jQuery("#gform_245")[0].checkValidity || jQuery("#gform_245")[0].checkValidity()){window["gf_submitting_245"]=true;} '/>

Notice the tabindex and onclick attributes, now here's the example from the documentation showing how you can change just the submit button:

// filter the Gravity Forms button type
add_filter("gform_submit_button", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
    return "<button class='button' id='gform_submit_button_{$form["id"]}'><span>Submit</span></button>";
}

By using the above example you are losing some of the attributes, the onclick attribute is used to prevent duplicate form submissions and for next and previous buttons it's also responsible for actually moving from one page to another so ideally we want to keep that.

So, how can we improve on the above example so it keeps all the important attributes we need while also making it universal so it can handle all three button types, and for bonus points use whatever label you assign to the next, previous and submit buttons in the form editor. Here's the code, you would add it to your theme's functions.php file or custom functionality plugin, you don't need the <?php from line 1.

Now I bet you're wondering what that gets you, well here's what the HTML for the new next, previous and submit buttons would look like:

<button type="button" id="gform_next_button_245_1" class="button gform_next_button" tabindex="2" onclick='jQuery("#gform_target_page_number_245").val("2"); jQuery("#gform_245").trigger("submit",[true]); '><span>Next</span></button>
<button type="button" id="gform_previous_button_245_4" class="button gform_previous_button" tabindex="5" onclick='jQuery("#gform_target_page_number_245").val("1"); jQuery("#gform_245").trigger("submit",[true]); '><span>Previous</span></button>
<button type="submit" id="gform_submit_button_245" class="button gform_button" tabindex="8" onclick='if(window["gf_submitting_245"]){return false;}  if( !jQuery("#gform_245")[0].checkValidity || jQuery("#gform_245")[0].checkValidity()){window["gf_submitting_245"]=true;} '><span>Submit</span></button>

So there you have it, all the important attributes from the <input> elements have been transferred over to the new <button> elements.

Unless your theme contains some <button> specific styles they will be rendered using the browsers default styles but you can of course add your own CSS to your theme stylesheet to style the buttons however you like. Here's one article that explains how you can style <button> elements http://www.sitepoint.com/build-a-better-button-in-css3/

Removing the Gravity Forms submit button

So you're creating a really cool form with Gravity Forms, maybe you're using Number fields to create a calculator, but you've hit a snag. All forms created using Gravity Forms have a submit button, and your awesome calculator doesn't need one, what are you going to do?

Well you could hide the button using CSS, the following when added to your theme stylesheet or wherever you add custom CSS would hide the footer therefore hiding the submit button.

.gform_wrapper .gform_footer {
    display: none;
}

The above example would affect all forms so if you only want to target a specific form you would switch from using the form wrapper class selector to using the form wrapper ID like so:

#gform_wrapper_10 .gform_footer {
    display: none;
}

Another way would be to hide it using conditional logic, you would do this by editing the form settings and configuring a condition for the form button that you know can never be met therefore your submit button will never be shown.

The above methods are fine but the submit button is still there, what if there was a way to actually remove the button, good news, there is. Gravity Forms has many hooks you can use, in this case gform_submit_button is the hook Gravity Forms provides so you can change the submit button, the example in the documentation shows how you can replace the <input> element with a <button> element.

But how do you use that hook to remove the submit button, well it's easier than you'd think, WordPress has a couple of readymade functions you can call on, so instead of using a custom function you can call on the WordPress __return_false function, by returning false to gform_submit_button no button will be included with the form.

The example below will remove the submit button from the form with the id 10

add_filter( 'gform_submit_button_10', '__return_false' );

To remove the submit button from all forms, simply remove the form id from the end of the hook name like so

add_filter( 'gform_submit_button', '__return_false' );

So one line of code added to your theme's functions.php file or custom functionality plugin and say goodbye to the submit button. How easy is that!

Include HTML fields and exclude other fields from Gravity Forms notifications

The Gravity Forms {all_fields} merge tag in notifications includes all fields for which the user entered or selected a value, it doesn't include HTML fields, Section Break descriptions, nor does it allow you to omit specific fields from the notification.

By adding the following code to your themes functions.php file you will gain the ability to include HTML fields, and Section Break field descriptions of your choice in the notifications and exclude fields of your choice from appearing in the notifications.

HTML fields will be treated just like any other field so you may want to give them more meaningful labels otherwise the notification will just include the default "HTML Block" label.

Also if your form uses conditional logic and your HTML field is hidden at the time the form is submitted the HTML field will not be included in the notification. Note: gf_exclude does not work with pricing fields.

Original posted on Google+

Some important news about how we are going to be handling Gravity Forms standard support as of today

Some important news about how we are going to be handling Gravity Forms standard support as of today

We are announcing a major change to how we handle standard support. It will no longer be handled via a forum system. We will now be handling standard support requests via the same ticketing system we utilize for Contact Us and Priority Support requests. Due to Gravity Forms explosive user growth …

If you use Gravity Forms and have recently started to experience issues installing add-ons or updates…

If you use Gravity Forms and have recently started to experience issues installing add-ons or updates you may want to check out the latest blog post over on gravityhelp.com #gravityforms  

We have seen a rise in the number of people reporting issues automatically updating Gravity Forms, downloading or updating Gravity Forms add-ons from within their WordPress Dashboard. Upon investigation, we have discovered that the issue is typically due to a shared IP address being blacklisted …

Earlier this year John Day posted about using time-based Gmail filters with Google Apps Script to aut…

Earlier this year John Day posted about using time-based Gmail filters with Google Apps Script to automatically archive and delete mail after a certain amount of time, since Google introduced the tabbed inbox I have used Johns example functions to come up with a function that will automatically delete mail from the Promotions category after 1 month and a second function that will automatically archive mail from the Social, Updates and Forums categories after 1 month.

function batchDeletePromotions() {
  var batchSize = 100 // Process up to 100 threads at once
  var threads = GmailApp.search('category:promotions older_than:1m');
  for (j = 0;j < threads.length;j+=batchSize) {
    GmailApp.moveThreadsToTrash(threads.slice(j,j+batchSize));
  }
}

function batchArchiveCategories() {
  var myCategories = {'"updates"':"1m",'"forums"':"1m",'"social"':"1m"};  
  var batchSize = 100; // Process up to 100 threads at once
  for(aCategory in myCategories) {
    var threads = GmailApp.search('label:inbox category:'+aCategory+' older_than:'+myCategories[aCategory]+'');
    for (j = 0;j < threads.length;j+=batchSize) {
      GmailApp.moveThreadsToArchive(threads.slice(j,j+batchSize));
    }
  }  
}

Check out John's post for the details about how to use them at http://www.johneday.com/422/time-based-gmail-filters-with-google-apps-script

Time for a new social media profile image for work

E & H Baxendale Ltd - new social media profile image
E & H Baxendale Ltd - old profile image

Today we updated our social media profile image, you can check it out in place on our Google+ page, Twitter stream, Facebook page and our Flickr photostream.

As you can see our old profile image was just our long rectangular logo (truss, joist and name) squashed and stretched to the specific sizes of each social media services profiles, which I think you will agree made for a cluttered image that didn't look great; so we were overdue for creating something much cleaner and better designed for the squarer proportions of social media profile images.

The new profile image is formed using the initials of our founders first names, Ernie and Harold, positioned so they touch forming a corner giving some perspective to the image and pointing to our founders surname positioned beneath and sized so it spans the full width of the initials E and H. As for colour, we chose to keep to our Bax blue roots and opted for a single colour logo which can be blue when used on a light background and white when used on a dark background.

Does this mean we will be ditching our existing truss, joist and name logo? In the short term no; we haven't made any decisions just yet and our existing logo is on our delivery vehicle, building signage, truss and joist production labels and most of our paperwork so would take time to change anyway.

Originally posted on November 23rd 2012 at http://www.eandhbaxendale.com/blog/new-social-media-profile-image/

Time for a new Kindle

I purchased my Kindle Keyboard back in 2010, since then it has served me well, the only real problem I have with it now is that there is a crack in the body running out of the bottom left corner of the screen which is slowly getting longer.

Back in September Amazon announced a refreshed line of Kindles which includes the Kindle Paperwhite which just happens to be front-lit and since I read mostly a night I thought that was a good idea and then I found out that it wouldn't be hitting the UK any time soon, I guessed March/April. How wrong I was because imagine my surprise when I visited the Amazon UK homepage last night to be met by the customary letter from Jeff Bezos introducing the Kindle Paperwhite to these shores.

So given the damage to my Kindle Keyboard and the amount of late night reading I do I immediately decided to pre-order a Kindle Paperwhite, they are scheduled to be released on 25th October but given the amount of demand I bet they run out fast. Hopefully I won't have too long to wait and may even get it by the end of the month.

I took a look at the customer discussion forum this morning over on the Amazon UK website was amused to find people angry about this new Kindle with built in light, with a number of people demanding a software update for their few months old Kindle Touch to enable the lights for them, how thick are some people that they think a software update can magic a piece of hardware into their last generation Kindle device.