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.

Notification Modification in gform_pre_submission

  1. I noticed the gform_pre_submission hook includes the $form OBJECT but not the $entry OBJECT.

    I'm attempting to change the subject line of the notification email based upon selections in the user's entry. Is there a way to access the $_POST or rgpost or $entry object from within gform_pre_submission?

    I've seen rgpost('input_#') a couple of places on the site and I was wondering if that was a function for retrieving the entry of an input.

    Thanks for your help.

    Posted 12 years ago on Wednesday November 21, 2012 | Permalink
  2. Yes, you can access all the $_POST values in the gform_pre_submission or gform_pre_submission_filter. The rgpost function just sanitizes the values a little bit so you're not directly reading the $_POST. Here is a simple example:

    [php]
    <?php
    // change the 14 here to your form ID
    add_filter('gform_pre_submission_filter_14', 'change_notification_subject');
    function change_notification_subject($form){
    	// grab the first and last name, parts of field 1
    	$fname = rgpost('input_1_3');
    	$lname = rgpost('input_1_6');
    
    	// modify the subject line of the user notification
    	$form['autoResponder']['subject'] = "$fname $lname: Today is your lucky day!";
    
    	// return modified form
    	return $form;
    }
    Posted 12 years ago on Wednesday November 21, 2012 | Permalink
  3. Very helpful. Thank you. I searched the documentation but didn't find anything on rgpost().

    Posted 12 years ago on Wednesday November 21, 2012 | Permalink
  4. I'm not sure where I learned that one. You could just access $_POST directly, but rgpost strips slashes. You could also use RGForms::post. The preferred method is rgpost. All 3 methods will get you the same value.

    Were you able to successfully modify your subject line?

    Posted 12 years ago on Wednesday November 21, 2012 | Permalink