Support » Plugin: Gravity Forms + Custom Post Types » How to get values from checkbox

Viewing 6 replies - 1 through 6 (of 6 total)
  • I have this issue as well for checkboxes.

    And for radio boxes no values are saved…

    Pondering this issue myself as well

    cdodge

    (@cdodgenewbcomputerbuildcom)

    Hello everyone,

    I have just spent a good 3 hours trying to solve this and I have found a solution that has worked perfectly for myself. I will try to explain as best I can and its not necessarily the best solution, but it works.

    You will need to use the following code for each checkbox field you have in order to fully populate all selected checkbox values –

    YOUR_FORM_ID = the ID of the Gravity Form You have created
    ACF_FIELDNAME = the exact Advanced Custom Fields Field Name of Your Checkbox Field Type.
    ACF_FIELD_KEY = The Field Key of your checkbox Field Type in Advanced Custom Fields. (To get the Field Key open up Custom Fields and go to “Screen Options” at the top of the screen and select “Show Field Key = Yes”

    Paste the following into functions.php

    add_action("gform_after_submission_YOUR_FORM_ID", "acf_post_submission", 10, 2);
    
    function acf_post_submission ($entry, $form)
    {
    $post_id = $entry["post_id"];
    $values = get_post_custom_values("ACF_FIELDNAME", $post_id);
    update_field("ACF_FIELD_KEY", $values, $post_id);
    }

    hi, anyone can help me.
    i have an gravity form. and need to send some value to a php function that calc a price.
    im using this in confirmations:

    <form method='POST' id='gform_2' action='http://www....prices.php'>
        <input type='hidden' name='sacado' value='{Nome completo para certificado:1}'/>
        <input type='hidden' name='endereco1' value='{Endereço e Bairro:6}'/>
        <input type='hidden' name='endereco2' value='{Cidade:7}'/>
        <input type='hidden' name='categoria' value='{Categoria:12}'/>
        <input type='hidden' name='pontuacao_cna' value='14'>
    </form>
    <script type="text/javascript">
        jQuery("#gform_2").submit();
    </script>

    and in the price php i have this funcion (part of this):

    $valor = number_format(calcula_preco($d,$categoria,$pontuacao_cna),2,',','.');
    $categoria = 1;
    $nosso_numero = incrementa_numero($sacado,$email);
    function calcula_preco($d,$categoria,$pontuacao_cna){
    	$categoria = trim($categoria);
    	if(strtotime($d) <= strtotime('2014-04-01')){
    		$preco = '500';
    	}else{
    		$preco = '500';
    	}
    	if($categoria == 'Medicos Socios Quites'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '400';
    		}else{
    			$preco = '400';
    		}
    	}
    
    	if($categoria == 'Medicos Socios Nao Quites'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '500';
    		}else{
    			$preco = '500';
    		}
    	}
    
    	if($categoria == 'Nao Socios'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '500';
    		}else{
    			$preco = '500';
    		}
    	}
    
    if($categoria == 'Residentes'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '250';
    		}else{
    			$preco = '250';
    		}
    	}
    
    if($categoria == 'Outros'){
    		if(strtotime($d) <= strtotime('2014-04-01')){
    			$preco = '250';
    		}else{
    			$preco = '250';
    		}
    	}
    	$pontuacao_cna = trim($pontuacao_cna);
    	if($pontuacao_cna == 'CNA'){
    		$preco = $preco + 25;
    	}
    
    return $preco;
    }

    in form, if user check ‘pontuacao cna’ the function must plus 25 usd in price. but is does not works.
    any idea, anyone can help me?
    thanks!

    Just adding my voice to the thread. I’m having the same issue with checkboxes. cdodge’s fix worked for me, but what a pain in the but to do that for every checkbox on every form.

    Hoping they fix this in the next update.

    If you require assistance then, as per the Forum Welcome, please post your own topic instead of tagging onto someone else’s topic.

    I am now closing this 10 month old topic as it references an older version of WordPress.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to get values from checkbox’ is closed to new replies.