Title: Problem with trans function
Last modified: August 22, 2016

---

# Problem with trans function

 *  Resolved [Sameer Panje](https://wordpress.org/support/users/sameerpanje/)
 * (@sameerpanje)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/problem-with-trans-function/)
 * I’m trying to update a form submission on my website. The code I’m using is as
   follows…
 *     ```
       require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBPermittedFunctions.php');
   
       function calc_balance_due ($var_booking_id) {
       require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
       $exp = new CFDBFormIterator ();
       $exp->export ('Booking Details', array ('show' => 'BalanceDue', 'filter'=>"booking-id=$var_booking_id"));    //booking-id is a unique key in the Booking Details Table
       while ($row = $exp->nextRow()) {
       	$var_balance_due = str_replace (',' , '' , $row ['BalanceDue']);
       }
       $var_paid_amount = $cf7->posted_data ['paid-amount'];
       $var_balance_due = number_format ($var_balance_due - $var_paid_amount);
       return $var_balance_due;
       }
   
       cfdb_register_function ('calc_balance_due');
   
       function before_sent_mail_actions () {
       $var_booking_id = get_query_var ('booking_id');
       $shortcode_text = "'[cfdb-table form=\"Booking Details\" trans=\"BalanceDue=calc_balance_due ('".$var_booking_id."')\" tfilter=\"booking-id='".$var_booking_id."']'";
       do_shortcode ($shortcode_text);
       }
   
       add_action ('wpcf7_before_send_mail' , 'before_sent_mail_actions');
       ```
   
 * I have set the Run any function in shortcode option under the plugin options 
   to true. But for some reason that I can’t figure out to save my life, the BalanceDue
   field on the Booking Details form just doesn’t get updated.
 * If I populate a dynamichidden field (using the CF7 Dynamic Text Extension plugin)
   on a form with the calc_balance_due function, it returns the desired value. And
   I can get around this problem by doing that. But that would only mean data duplication
   and redundancy.
 * Could someone please help me with where I’m going wrong here? Thanks a ton in
   advance.
 * S
 * [https://wordpress.org/plugins/contact-form-7-to-database-extension/](https://wordpress.org/plugins/contact-form-7-to-database-extension/)

Viewing 1 replies (of 1 total)

 *  Thread Starter [Sameer Panje](https://wordpress.org/support/users/sameerpanje/)
 * (@sameerpanje)
 * [11 years, 9 months ago](https://wordpress.org/support/topic/problem-with-trans-function/#post-5254124)
 * My bad. I got it all wrong. I understood the trans functions to be meant for 
   updating values in the submissions database. Feeling so stupid. I was already
   using standard php functions to format my output. I guess I’ll have to look at
   writing the data into my own custom table instead of saving it on the plugins
   database to achieve what I need.
 * Sorry for opening this thread. I’ll mark it as resolved.
 * Cheers…& thanks for a great plugin. 🙂
 * S

Viewing 1 replies (of 1 total)

The topic ‘Problem with trans function’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/contact-form-7-to-database-extension_ffffff.
   svg)
 * [Contact Form DB](https://wordpress.org/plugins/contact-form-7-to-database-extension/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/contact-form-7-to-database-extension/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/)
 * [Active Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/contact-form-7-to-database-extension/reviews/)

## Tags

 * [Contact Form DB](https://wordpress.org/support/topic-tag/contact-form-db/)

 * 1 reply
 * 1 participant
 * Last reply from: [Sameer Panje](https://wordpress.org/support/users/sameerpanje/)
 * Last activity: [11 years, 9 months ago](https://wordpress.org/support/topic/problem-with-trans-function/#post-5254124)
 * Status: resolved