Quantcast
Channel: Snippets Archives - Gravity Wiz
Viewing all articles
Browse latest Browse all 196

Random Fields with Gravity Forms

$
0
0

This snippet provides an easy way to show a random number of fields on your Gravity Forms. Let’s say you’re using Gravity Forms to power a simple questionnaire. You have five (5) questions total but only want to show (2) per submission. This snippet lets you do that!

View this code snippet on GitHub.

How do I install this snippet?

Just copy and paste the code into your theme’s functions.php file.

Do I need to modify this snippet to work with my form?

Yes! This snippet is a little different than some of the other snippets on the site. You see this code new GFRandomFields(12, 2, array(1,2,3,4,5)); all the way down at the bottom? Well, that is all you’ll need to modify!

  1. Update the 12 to the ID of your form.
  2. Update the 2 to the number of random fields you want to show at a time.
  3. Lastly, update the array(1,2,3,4,5) to the field IDs which should be random. Any field ID you do not include in this array will considered a “static” field and show up on every form load.

To summarize: new GFRandomFields(form_id, display_count, random_field_ids)

Summary

Make sure you check out the demo to see this snippet in action. This will be converted to a perk very soon!


Viewing all articles
Browse latest Browse all 196

Latest Images

Trending Articles



Latest Images