PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Captcha default value

  1. Hello,

    I am using Really Simple Captcha plugin for my captcha field.

    How ever I can't seem change the default value using 'gform_pre_render'

    // FORM FOOTER CAPTCHA
    add_filter('gform_pre_render', 'add_captcha_value');
    function add_captcha_value($form){
        $_POST['input_4'] = 'Please enter captcha';
        return $form;
    }

    See form source... http://i.imgur.com/10Pu6.png

    I cant get any field pre-rendering to apply?

    Also how can I get this hook to only apply to my footer form?

    Any help would be much appreciated, thank you for your time.

    Josh

    Posted 5 years ago on Wednesday July 11, 2012 | Permalink
  2. $_POST is not available in gform_pre_render. Changing that value is not possible and would not work in your case.

    Please see this documentation:
    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    What is the field which holds the value you want to change? Can you post a link to your form?

    Posted 5 years ago on Wednesday July 11, 2012 | Permalink
  3. Hello,

    Thanks for quick response.

    See on a previous website, I used this hook to add a default value to my confirm email field.

    add_filter('gform_pre_render', 'add_confirm_value');
    function add_confirm_value($form){
    
        $_POST['input_6_2'] = 'Confirm Your E-mail';
    
        return $form;
    }

    This worked great. So thought if I used this same hook I could do the same on the captcha input.

    The form/website is hidden at the mo, can't share.

    But this is the code of my form #gform_1. Screenshot

    I know how I could do this with jquery but if there was a PHP way of doing it then that would be cool.

    Thanks

    Posted 5 years ago on Wednesday July 11, 2012 | Permalink
  4. Any suggestions on this please?

    Thank you.

    Posted 5 years ago on Thursday July 12, 2012 | Permalink
  5. David Peralty
    Administrator

    I don't know if you can pass a value like that to the Really Simple Captcha plugin and have it work as default. Do you have any documentation on Really Simple Captcha related to setting a default value? In Gravity Forms, on a normal field, I would just ask if you had Allow Populate Dynamically checked in the field settings.

    Posted 5 years ago on Thursday July 12, 2012 | Permalink
  6. OK fair enough I can see what you mean as it is a third party thing.

    No option for dynamic population so I will just use jQuery - not a problem.

    Whilst we are on topic, how can I use this pre form rendering on the name field (normal mode)

    // PRE FORM RENDERING
    add_filter('gform_pre_render', 'add_subscribe_value');
    function add_subscribe_value($form){
        $_POST['input_1_3'] = 'First Name';
        $_POST['input_1_6'] = 'Last Name';
        return $form;
    }

    This is what I have tried above?

    I think gravity forms should allow default value on everything. It allows default value on on name field (simple mode).

    Thank you for your time.

    Josh

    Posted 5 years ago on Thursday July 12, 2012 | Permalink
  7. David Peralty
    Administrator

    You can't use POST for fields that haven't been loaded yet.

    You want to look at the documentation on this hook here:
    http://www.gravityhelp.com/documentation/page/Gform_pre_render

    And you can set default values on most fields. Go to Advanced for any field and most of them should include an option to set a default value from within the form builder.

    Posted 5 years ago on Thursday July 12, 2012 | Permalink
  8. Hi David,

    Thanks for your response.

    But default values do not exist on name field in 'Normal mode' - see screenshot

    So I have resorted to using this...

    add_filter('gform_field_value_first_name', 'first_name_population_function');
    function first_name_population_function($value){
        return 'First Name';
    }
    add_filter('gform_field_value_last_name', 'last_name_population_function');
    function last_name_population_function($value){
        return 'Last Name';
    }

    But is not great because the form thinks 'First Name' and 'Last Name' are actual entries if someone submits the form without actually filling it in.

    This is why I need default values... see my form

    Posted 5 years ago on Friday July 13, 2012 | Permalink
  9. David Peralty
    Administrator

    You are correct about it not existing for Normal mode. It does exist for simple mode. You could then create a quick validation hook to test against those default values using:
    http://www.gravityhelp.com/documentation/page/Gform_field_validation

    Basically the same as how you put the value in, you can test against those values and pass back an error if someone keeps them as the defaults.

    Posted 5 years ago on Friday July 13, 2012 | Permalink