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://ww.wp.xz.cn/plugins/contact-form-7-to-database-extension/
The topic ‘Problem with trans function’ is closed to new replies.