Skip to content

Instantly share code, notes, and snippets.

@leepettijohn
Created July 28, 2017 18:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leepettijohn/4225a02f0a2060e623788950b080c21d to your computer and use it in GitHub Desktop.
Save leepettijohn/4225a02f0a2060e623788950b080c21d to your computer and use it in GitHub Desktop.
Gravity Forms - Checkboxes to Updating Tags
<?
// see this gist for creating dynamic checkboxes - https://gist.github.com/leepettijohn/28499de95fae967845728ec0be7a43d0
$checktag = 1; //This should stay as 1
$beertag = 16; //This should be the field_id of the checkbox field
while (isset($entry["{$beertag}.{$checktag}"])){
if (!empty($entry["{$beertag}.{$checktag}"])){
wp_set_post_terms($new_beer_id,$entry["{$beertag}.{$checktag}"],'post_tag',true);
}
$checktag++;
if ($checktag % 10 == 0){
// for whatever reason, GF doesn't like checkbox ids in multiples of 10
$checktag++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment