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.

Custom Subject for Notifications

  1. Hi,

    I am creating a "Tell a friend" type form, and in the form the user can optionally specify the subject of the email.

    When I come to send the notification out, what I would like to do, is use that subject if it is not empty otherwise use a default subject line.

    Following from the info I found in this forum post: http://forum.gravityhelp.com/topic/in-replace_variables-what-is I came up with the code below however it doesn't work.

    Added to functions.php:

    add_filter("gform_pre_submission_filter", "editfields");
    
    function editfields($form){
        // only action on the sendtofriend form id=1
        if($form["id"] != 1) {
            return;
    	}
    
    	// Set the subject line to the users if they entered one, else set to default
    	if (trim($_POST["input_10"]) != "") {
    		$subject = trim($_POST["input_10"]);
    	} else {
    		$subject = 'hopkinsrealty.com.au - property from a friend';
    	}
    
        $form["notification"]["subject"] = $subject;
        return $form;
    }

    Thanks any help would be appreciated!

    Posted 14 years ago on Thursday June 17, 2010 | Permalink
  2. An easier way to accomplish this would be to use a default value on the field you use for the subject. So pre-populate the subject field and if they want to edit it to change it, they can edit it and change it. This would require no code changes to accomplish.

    Posted 14 years ago on Thursday June 17, 2010 | Permalink