<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Get checked checkboxes</title>
		<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes</link>
		<description>Gravity Support Forums Topic: Get checked checkboxes</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 17:05:27 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/get-checked-checkboxes" rel="self" type="application/rss+xml" />

		<item>
			<title>gingram815 on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-25576</link>
			<pubDate>Mon, 16 May 2011 08:46:27 +0000</pubDate>
			<dc:creator>gingram815</dc:creator>
			<guid isPermaLink="false">25576@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;This works great!! Sorry I didn't reply earlier.  Thank you so much.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-23707</link>
			<pubDate>Tue, 19 Apr 2011 16:46:31 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">23707@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Here is a more universal solution that should fulfill your requirements as well as anyone else who is trying to use a checkbox field as a post custom field:&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;Paste this code into your theme's &#60;em&#62;functions.php&#60;/em&#62;:&#60;br /&#62;
&#60;a href=&#34;http://pastie.org/1813050&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/1813050&#60;/a&#62;
&#60;/li&#62;
&#60;li&#62;Now add a CSS class to the field in the GF admin using the following format:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;custom_field_{custom_field_name}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;So to add the selected checkbox inputs as values for a custom field titled &#34;sports&#34; you would add the CSS class &#34;custom_field_sports&#34;.&#60;/li&#62;
&#60;/ol&#62;
&#60;p&#62;That's it. Let me know how it works.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gingram815 on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-23675</link>
			<pubDate>Tue, 19 Apr 2011 11:17:53 +0000</pubDate>
			<dc:creator>gingram815</dc:creator>
			<guid isPermaLink="false">23675@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I have worked on this more.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;//Add checkbox info from gravity forms to the custom fields of each post
add_action(&#38;quot;gform_post_submission_2&#38;quot;, &#38;quot;set_post_custom_field&#38;quot;, 10, 2);
function set_post_custom_field($entry, $form){

$postid = $entry[&#38;quot;$post_id&#38;quot;]; //get post id associated with entry 

 $parts = &#38;quot;&#38;quot;;
$field_ids = array_keys($entry); //get all field ids of entry
 foreach($field_ids as &#38;amp;$field_id){
	if(substr($field_id,0,2) == 89){    //define $parts as all values from field ids beginning with 89
$parts.= $entry[$field_id] . &#38;#39;,&#38;#39;;}
}

$parts = explode(&#38;quot;,&#38;quot;, $parts);
	//updating custom fields with each value from above into same key
	foreach($parts as &#38;amp;$part){
		if(!empty($part)){
		update_post_meta($postid, &#38;#39;part_of_plant_used&#38;#39;, $part);
		}
		}
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I am getting an error back because $entry is an object and not an array.  So the array_keys() function is not working (line 8).  Does anyone have another way of getting all the keys of the entry as an array?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gingram815 on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-23644</link>
			<pubDate>Mon, 18 Apr 2011 23:17:04 +0000</pubDate>
			<dc:creator>gingram815</dc:creator>
			<guid isPermaLink="false">23644@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I am working on a very similar issue, but I am attempting to place checkbox values into custom fields with each value under the same key.  It seems like I figured out how to do it but it is not working.&#60;br /&#62;
Here is my code&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php
//Add checkbox info from gravity forms to the custom fields of each post created by each entry
add_action(&#38;quot;gform_post_submission&#38;quot;, &#38;quot;set_post_custom_field&#38;quot;, 10, 2);
function set_post_custom_field($entry, $form){

$postid = $entry[&#38;quot;$post_id&#38;quot;]; //get post id associated with entry
$field_ids = array_keys($entry); //get all field ids of entry
foreach($field_ids as &#38;amp;$field_id){
	if(substr($field_id,0,2) == 89){    //define $parts as all values from field ids beginning with 89
$parts = $entry[$field_id];}
}
	//updating custom fields with each value from above into same key
	foreach($parts as $part){
		if(!empty($part)){
		update_post_meta($postid, &#38;#39;part_of_plant_used&#38;#39;, $part);
		}
		}
} ?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This is pasted into my functions.php.&#60;br /&#62;
I can't see that it would matter, but the post is a custom post type.&#60;br /&#62;
Here is the form page: &#60;a href=&#34;http://herbalrepertory.throughwoods.com/post-a-new-herb/&#34; rel=&#34;nofollow&#34;&#62;http://herbalrepertory.throughwoods.com/post-a-new-herb/&#60;/a&#62;&#60;br /&#62;
Any help would be greatly appreciated.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>escapade_carbet on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-10603</link>
			<pubDate>Thu, 30 Sep 2010 07:24:12 +0000</pubDate>
			<dc:creator>escapade_carbet</dc:creator>
			<guid isPermaLink="false">10603@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I found a solution with a different approach after noticing that $entry array was properly filled with values of checked checkboxes. Here is my code snippet:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_post_submission&#38;quot;, &#38;quot;insert_custom_taxonomies&#38;quot;,10,2);
function insert_custom_taxonomies($entry, $form){

	if($form[&#38;quot;id&#38;quot;] !=1)
        return;

    $post_id = $entry[&#38;quot;post_id&#38;quot;];

    $choices_services = &#38;quot;&#38;quot;;
    $choices_access = &#38;quot;&#38;quot;;

	$entry_ids = array_keys($entry);

	foreach($entry_ids as $entry_id){
        if(substr($entry_id,0,2) == 25) $choices_services.= $entry[$entry_id].&#38;#39;,&#38;#39;;
        if(substr($entry_id,0,2) == 24) $choices_access.= $entry[$entry_id].&#38;#39;,&#38;#39;;
    }

    wp_set_object_terms($post_id, explode(&#38;quot;,&#38;quot;, $choices_services), &#38;quot;service&#38;quot;);
    wp_set_object_terms($post_id, explode(&#38;quot;,&#38;quot;, $choices_access), &#38;quot;access&#38;quot;);

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I hope this will help somebody else.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>escapade_carbet on "Get checked checkboxes"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/get-checked-checkboxes#post-10526</link>
			<pubDate>Tue, 28 Sep 2010 22:23:41 +0000</pubDate>
			<dc:creator>escapade_carbet</dc:creator>
			<guid isPermaLink="false">10526@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hello,&#60;/p&#62;
&#60;p&#62;I'm using last version of Gravity Forms (1.4.3.1) and it was very easy to set up a complex and lengthy form. The purpose of the form is to create a custom post type. This part is working thanks to hints I found on this forum. I'm trying now to set up checkboxes that will populate custom taxonomies when values are checked.&#60;/p&#62;
&#60;p&#62;More details here:&#60;br /&#62;
- List A of checkboxes (id=24) for custom taxonomy 'access'&#60;br /&#62;
- List B of checkboxes (id=25) for custom taxonomy 'services'&#60;/p&#62;
&#60;p&#62;Here is my PHP code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_filter(&#38;quot;gform_post_submission&#38;quot;, &#38;quot;insert_custom_taxonomies&#38;quot;,10,2);
function insert_custom_taxonomies($entry, $form){

	if($form[&#38;quot;id&#38;quot;] !=1)
        return;

    $post_id = $entry[&#38;quot;post_id&#38;quot;];

    $choices_services = &#38;quot;&#38;quot;;
    $choices_access = &#38;quot;&#38;quot;;

    foreach($form[&#38;quot;fields&#38;quot;] as &#38;amp;$field){
        if($field[&#38;quot;id&#38;quot;] == 25){
        	foreach($field[&#38;quot;choices&#38;quot;] as $choice){
	            $field_value = !empty($choice[&#38;quot;value&#38;quot;]) &#124;&#124; $field[&#38;quot;enableChoiceValue&#38;quot;] ? $choice[&#38;quot;value&#38;quot;] : $choice[&#38;quot;text&#38;quot;];
    	        $choices_services.= $field_value.&#38;#39;,&#38;#39;;
    		}
        }

        if($field[&#38;quot;id&#38;quot;] == 24){
        	foreach($field[&#38;quot;choices&#38;quot;] as $choice){
	            $field_value = !empty($choice[&#38;quot;value&#38;quot;]) &#124;&#124; $field[&#38;quot;enableChoiceValue&#38;quot;] ? $choice[&#38;quot;value&#38;quot;] : $choice[&#38;quot;text&#38;quot;];
    	        $choices_access.= $field_value.&#38;#39;,&#38;#39;;
    		}
        }
    }

    wp_set_object_terms($post_id, explode(&#38;quot;,&#38;quot;, $choices_service), &#38;quot;service&#38;quot;);
    wp_set_object_terms($post_id, explode(&#38;quot;,&#38;quot;, $choices_access), &#38;quot;access&#38;quot;);    

}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This does not work as my vars 'choices_access' and 'choices_services' are empty before calling  'wp_set_object_terms'.&#60;/p&#62;
&#60;p&#62;I've tried var_dump($choice) for debugging purpose in &#34;foreach&#34; loop, but even if I check a checkbox in the form, &#34;IsSelected&#34; property is set to &#34;false&#34; after submission.&#60;/p&#62;
&#60;p&#62;- Am I using a wrong hook to populate my taxonomies? I've tried 'gform_pre_submission' hook, without any success.&#60;br /&#62;
- Is there a way to know if a checkbox was checked before hitting submission button?&#60;/p&#62;
&#60;p&#62;Anyone can help?&#60;br /&#62;
Thanks!&#60;/p&#62;
&#60;p&#62;Vincent
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
