GET MORE OUT OF
GRAVITY FORMS
VANCOUVER WORDPRESS MEET-UP – MAY 15, 2014
WHAT WE'LL COVER:
1. The challenge
2. Gravity Forms vs. ...
3. Get more out of the box
4. Get more with hooks
5. Some gotc...
THE CHALLENGE
MUST-HAVES
A form that would accept user-submitted nominations
and save them as a custom post type
A voting mechanism for ...
SOLUTION?
Gravity Forms!
vs.
Single license: $39 Single license: $0 + ???
User analytics: $19
File uploads: $39
Front-end posting: $39
Multi-part f...
OUT OF THE BOX MAGIC
FORM FIELDS IN A SNAP
USER-SUBMITTED POSTS
BUT WHAT ABOUT CPTS?
There's a plugin for that.
NEEDED TO TURN THIS...
INTO THIS:
GRAVITY FORMS +
CUSTOM POST TYPES
Find it WP plugin directory:
wordpress.org/plugins/gravity-forms-custom-post-types/
Bett...
FORMS IN MODALS
(or another modal plugin) will allow you to easily
show or or hide your form on demand.
Fancybox
IN A THEME FILE
hostedwith ❤by
<div id="voting‐form" style="display:none">
  <?php echo do_shortcode( '[gravityform id="6"...
IN THE WILD
IN THE WILD
GET MORE WITH HOOKS
Around 200 actions & filters you can use to extend GF...
www.gravityhelp.com/documentation/page/Develo...
WHERE DOES IT GO?
1. Your theme's functions.php file
2. A functionality plugin
AUTO-POPULATE FIELDS
Many ways to go about this!
gform_field_value_[your custom param]
gform_pre_render_[your form ID]
gform_field_value_[your custom param]
Use this filter for text fields or pre-selection of options in a dropdown, etc. See ...
gform_field_value_[your custom param]
gform_pre_render_[your form ID]
Use this filter to pre-populate choices in a dropdown, etc. See the offcial docs .here
Che...
CUSTOM VALIDATION
Be the boss of your form AND database!
gform_validation_[your form ID]
gform_validation_[your form ID]
hostedwith ❤by
function my_custom_validation( $validation_result ) {
    $form = $validati...
RESTRICT UPLOAD SIZE
There's no way to do this out of the box and you may not
want users uploading 32MB files!
There is a ...
CUSTOM CHECK FOR
DUPLICATES
Preventing duplicates is easy... preventing a single user from
submitting the same field value...
SOME GOTCHAS
Duplicate prevention (use )
Ajax and captcha
And on the topic of spam...
this plugin
THAT'S ALL FOLKS!
Find me: and@mandiwise mandiwise.com
All of the snippets: gist.github.com/mandiwise
Upcoming SlideShare
Loading in …5
×

Get More Out of Gravity Forms

1,666 views
1,569 views

Published on

From my Vancouver WordPress Meet-up talk about to do neat-o things with the Gravity Forms plugin.

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,666
On SlideShare
0
From Embeds
0
Number of Embeds
484
Actions
Shares
0
Downloads
4
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Get More Out of Gravity Forms

  1. 1. GET MORE OUT OF GRAVITY FORMS VANCOUVER WORDPRESS MEET-UP – MAY 15, 2014
  2. 2. WHAT WE'LL COVER: 1. The challenge 2. Gravity Forms vs. ... 3. Get more out of the box 4. Get more with hooks 5. Some gotchas
  3. 3. THE CHALLENGE
  4. 4. MUST-HAVES A form that would accept user-submitted nominations and save them as a custom post type A voting mechanism for each award category that only allowed a person to vote once per person per category
  5. 5. SOLUTION? Gravity Forms!
  6. 6. vs. Single license: $39 Single license: $0 + ??? User analytics: $19 File uploads: $39 Front-end posting: $39 Multi-part forms: $39 Conditional logic: $29 TOTAL: $165
  7. 7. OUT OF THE BOX MAGIC
  8. 8. FORM FIELDS IN A SNAP
  9. 9. USER-SUBMITTED POSTS
  10. 10. BUT WHAT ABOUT CPTS? There's a plugin for that.
  11. 11. NEEDED TO TURN THIS...
  12. 12. INTO THIS:
  13. 13. GRAVITY FORMS + CUSTOM POST TYPES Find it WP plugin directory: wordpress.org/plugins/gravity-forms-custom-post-types/ Better yet, get it from Github*: github.com/bradvin/gravity-forms-custom-post-types *No PHP error notices with WP DEBUG on.
  14. 14. FORMS IN MODALS (or another modal plugin) will allow you to easily show or or hide your form on demand. Fancybox
  15. 15. IN A THEME FILE hostedwith ❤by <div id="voting‐form" style="display:none">   <?php echo do_shortcode( '[gravityform id="6" title="false" description="false" ajax="true"]' ) ?> </div> <a href="#voting‐form" class="fancybox button">Vote Now</a> viewrawGravityFormsandFancybox GitHub Initially hidden form + Ajax submitting= no-fuss modal perfection!
  16. 16. IN THE WILD
  17. 17. IN THE WILD
  18. 18. GET MORE WITH HOOKS Around 200 actions & filters you can use to extend GF... www.gravityhelp.com/documentation/page/Developer_Docs
  19. 19. WHERE DOES IT GO? 1. Your theme's functions.php file 2. A functionality plugin
  20. 20. AUTO-POPULATE FIELDS Many ways to go about this! gform_field_value_[your custom param] gform_pre_render_[your form ID]
  21. 21. gform_field_value_[your custom param] Use this filter for text fields or pre-selection of options in a dropdown, etc. See the offcial docs .here hostedwith ❤by function my_city_population_function( $value ){     return 'Vancouver'; } add_filter( 'gform_field_value_my_city', 'my_city_population_function' ); viewrawDynamicallyPopulateGravityFormsTextField GitHub
  22. 22. gform_field_value_[your custom param]
  23. 23. gform_pre_render_[your form ID] Use this filter to pre-populate choices in a dropdown, etc. See the offcial docs .here Check out a sample Gist.
  24. 24. CUSTOM VALIDATION Be the boss of your form AND database! gform_validation_[your form ID]
  25. 25. gform_validation_[your form ID] hostedwith ❤by function my_custom_validation( $validation_result ) {     $form = $validation_result["form"];       // Sorry, you don't get to live in Vancouver...          if ( $_POST['input_1'] == 'Vancouver' ) {           $validation_result["is_valid"] = false;           foreach ( $form["fields"] as &$field ) {               // NOTE: Replace 1 with the field you would like to validate                          if ( $field["id"] == "1" ) {                 $field["failed_validation"] = true;                 $field["validation_message"] = "Sorry, you can't enter Vancouver here!";                 break;             }         }     }       // Assign modified $form object back to the validation result     $validation_result["form"] = $form;     return $validation_result; } add_filter( 'gform_validation_[your form ID]', 'my_custom_validation' ); viewrawGravityFormsCustomValidationExample GitHub See the offcial docs .here
  26. 26. RESTRICT UPLOAD SIZE There's no way to do this out of the box and you may not want users uploading 32MB files! There is a plugin for that, but it's buggy. Instead... Check out this Gist.
  27. 27. CUSTOM CHECK FOR DUPLICATES Preventing duplicates is easy... preventing a single user from submitting the same field value twice is harder. Check out this Gist.
  28. 28. SOME GOTCHAS Duplicate prevention (use ) Ajax and captcha And on the topic of spam... this plugin
  29. 29. THAT'S ALL FOLKS! Find me: and@mandiwise mandiwise.com All of the snippets: gist.github.com/mandiwise

×