Sending email after submission confirmation


Scripting example on how you can confirm a submission and then send an email. In this case we will use a custom link sent via email, which after being accessed, will send another email.

Note: this is entirely different than the submission confirmation feature. In the example from this article, we're using a custom approach to create our own link that will be used to confirm the submission and trigger your email.

By using the latest RSForm!Pro version, you can now defer User, Admin or Additional emails from the Form Properties > Form Info > Submission area,, while the 'Enable Confirmation by Email' option is enabled, without needing a custom scripting approach.


Let's assume we have 2 emails in our form, the User and Admin emails, and we want the Admin Email to be only sent after the user confirms their submission through our custom link.

You can start off by firstly configuring your emails as needed, then follow these steps:

  1. Creating the custom link
    • enable the "Enable Confirmation By Email" option (while editing your form > Form Properties > Form Info).
    • add a Support Ticket element so we can have a hash in our link which will be tied with the according submission (in order to prevent users from confirming other submissions).
    • edit your User Email body and place the link (you'll need to replace, your website, the number 10 with your exact form ID, and the support ticket placeholder based on the name you've given to your element; case sensitive):

      This is basically your form's URL, though we've included 2 extra parameters. If you can't find your form's ID, go to Components > RSForm!Pro > Manage Forms > last column from the listing.

  2. Main script
  3. Navigate to backend > Components > RSForm!Pro > Manage Forms > your form > Form Properties > PHP Scripts > "Scripts called on form Display" area > add the following and replace the Support Ticket name:

              //replace the Support Ticket name with the one you've given:
              $supportTicket = "mySupportTicketNameHere";
              //getting parameter values:
              $app = JFactory::getApplication();
              $sid = $app->input->getInt('subId');
              $hash = $app->input->getVar('hash');
              //checking if parameters are available:
              if(!empty($sid) && !empty($hash)){
                $db = JFactory::getDBO();
                $db->setQuery("SELECT `FieldValue` FROM #__rsform_submission_values WHERE `FieldName`='".$supportTicket."' AND `SubmissionId` = '".$sid."'");
                //checking if the hash matched the submission ID:
                  //This confirms the submission:
                  $db->setQuery("UPDATE `#__rsform_submissions` SET `confirmed` = 1 WHERE `SubmissionId` = '".$sid."'");
                  //Confirmation message shown after clicking our custom link:
                  $formLayout = "<p>Here you can add your desired submission confirmation message, including HTML.</p>";
                  //the following triggers your form's emails:
  4. Preventing User Email from being sent once again after confirming the submission
  5. While editing your form > Form Properties > PHP Email Scripts > Script called before the User Email is sent > add:

                $userEmail['to'] = '';
  6. Preventing Admin Email from being sent upon submit
  7. While editing your form > Form Properties > PHP Email Scripts > Script called before the Admin Email is sent > add:

                $adminEmail['to'] = '';

10 persons found this article helpful.

Was this article helpful?

Yes No
Sorry about that