Run custom php code in form WordPress – Visual Form Builder Pro

Here is the page which I am working on
http://grmaedu.com/application/

The form is made using a WordPress plugin called Visual Form Builder Pro. The form is working fine and all the data gets emailed nicely to a defined email address. Also an automatic Roll Number is generated at the time of submission.

Read More

Now my issue is, I want the roll number that is displayed “after” the form, to be emailed along with the other form values. Here is the php code that I am using to generate the roll number:

<?php

/* Define Connection properties */

$servername = "localhost";
$username = "grmaedu_wp2";
$password = "*****";
$dbname = "grmaedu_wp2";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT entries_id FROM `wp_vfb_pro_entries` ORDER BY entries_id DESC LIMIT 1";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
  // get the last submitted id number
  while ($row = mysqli_fetch_assoc($result)) {
    $a = $row["entries_id"];
    $a++; // add 1 to it for a new roll number
    echo "<h3>Your Roll Number assigned is: " . $a . "</h3>";
  }
} else {
  echo "0 results";
}

mysqli_close($conn);
?> 

How do i make this particular below code to get submitted and emailed along with the other form values?

echo "<h3>Your Roll Number assigned is: " . $a . "</h3>";

Related posts

1 comment

  1. Just diving into this, the best way I’d assume is to use the VFB hooks. Either use the vfbp_form_action hook and completely replace the whole processing or use the vfbp_after_save_entry hook to save the value and somehow send it by mail.

    See also https://docs.vfbpro.com/category/49-hooks

Comments are closed.