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.

gform admin pre render

  1. Alex
    Member

    i can't get my gform admin pre render to work. here's my code:
    http://pastebin.com/e63v8RXA

    Nothing shows in the notification settings of any form. I want 'gsm' to appear as an option for me to route email. technically there may be an easier solution.

    The 'gsm' value of 'src' is generated via a cookie that I solved from this topic:
    http://www.gravityhelp.com/forums/topic/gform-pre-render-and-cookies

    If gsm appears in the form (which has been tried and tested) I want the form to be sent to an additional email. Is gform_admin_pre_render the best way to do this, and if yes, why this code isn't working

    Posted 12 years ago on Monday January 23, 2012 | Permalink
  2. Alex
    Member

    surely someone here knows how to solve this?!

    Posted 12 years ago on Wednesday January 25, 2012 | Permalink
  3. Hello Alex,
    I can give you hand with this.
    The gform_admin_pre_render is only fired on the entry detail page, so you won't see your custom choices on the notification page.

    It seems to me that what you need to be using is either the gform_autoresponder_email or the gform_notification_email. Both of them let you change the list of email address that the notifications are sent to. The difference is that gform_autoresponder_email applies to the user notification emails and gform_notification_email applies to the admin notification emails.
    The idea is to use one of these hooks and test if "gsm" was checked. If so, add the extra email address to the list of emails. The following pages have some examples on how to use these hooks
    http://www.gravityhelp.com/documentation/page/Gform_autoresponder_email
    http://www.gravityhelp.com/documentation/page/Gform_notification_email

    Good luck and let me know if you need any more help.

    Posted 12 years ago on Friday January 27, 2012 | Permalink
  4. Alex
    Member

    Hi Alex,

    Thanks for this. Let me start coding and I'll update you on how it goes...

    Posted 12 years ago on Friday January 27, 2012 | Permalink
  5. I have a simple but elegant solution for those of you trying to use pre_render to populate address and name fields. I found no other way to pre-populate a form... There is a simple way to process check boxes too.

    <?php
    $unencode = '';  // You need to populate the entry data or author_meta here for processing.
    
    add_action('wp_footer', 'pre_render_fields', 9999);  // add action to load the jQuery population of form fields.
    function pre_render_fields(){
    
    ?>
    <script type="text/javascript">
    	jQuery(document).ready(function($){
    		<?php foreach($unencode as $key => $val){
    			// Check Array to only populate fields with a "." period.
    			if(strpos($key, '.') !== false && $val !=== ''){
    				echo '$("#input_6_'.str_replace('.', '_',$key).'").val("'.$val.'");';
    			}
    		} ?>
    	});
    </script>
    <?php } ?>

    For checkboxes you can use something like this below:

    echo '$("#choice_'.str_replace('.', '_',$key).'").prop("checked", true);';
    Posted 12 years ago on Thursday March 1, 2012 | Permalink