Mattmcca
Forum Replies Created
-
Hello
https://drive.google.com/drive/folders/1V02RxLSng0CUhqjnMeeu0KlqJm_OGjPJ?usp=share_link
I would like to create a select statement that gets the email of the user and populate it in Hiddenfield2 , i have attached both the form and the code that i am using. Is there an action that be called pleaseThanks a lot this helps a lot, I managed to implement it
Hi Thanks for this it helped, i just have a follow up question, i dont know if you would be able to help on this , for the get_users function is there a way to get the display name instead please
Hello sure, when loading the page you wont get any html code as it done from the database based on the logged in user.
https://staging2.virs.com.mt/dealer-top-up/
I am including a screenshot for reference, I would like to send the highlighted in the email notification. I know the field id but when I include that field id it is ignored
https://drive.google.com/file/d/1l-GwxPCeoM9iuRkz1yj2lcVbyTSPRNls/view?usp=share_linkHi All, I managed to solve this issue myself, after a lot of trial and error. As a way of helping others that may still be new I have upload my code to github for all to see. I believe in karma do good and good comes your way
https://github.com/mccamatt92/Forminator-insert-into-table/blob/main/forminator-insert-into-database.phpHello Just an update, I have converted the code to use only php removing all JavaScript , but it is still not working, any advice as to what i am doing wrong or a way to debug
<?php /** *Plugin Name: Forminator Purschase Extenstion *Author : Matthias McCarthy *Description: An extenstion for Forminator to insert transactions after submitting a form *Version: 1.0.1 * License: GPLv2 or later * */ if ( ! defined( 'ABSPATH' ) ) { exit; } // No need to do anything if the request is via WP-CLI. if ( defined( 'WP_CLI' ) && WP_CLI ) { return; } if ( ! class_exists( 'Forminator_Insert_Credit' ) ) { class Forminator_Insert_Credit { private static $_instance = null; public static function get_instance() { if( is_null( self::$_instance ) ){ self::$_instance = new Forminator_Insert_Credit(); } return self::$_instance; } public function __construct() { $this->init(); // Ajax method (action) add_action( 'forminator_form_after_handle_submit', 'insertIntoCreditLog', 10, 2); add_action('forminator_form_after_save_entry', 'insertIntoCreditLog', 10,2); add_filter( 'forminator_form_ajax_submit_response','insertIntoCreditLog', 10,2); // Post method (filter) add_filter( 'forminator_form_submit_response', 'insertIntoCreditLog', 10,2); } public function insertIntoCreditLog($form_id, $response) { if ($response['success']){ if ($form_id == MyFormID){ $numberofbookings = $_post['number-1']; $current_user = get_current_user_id(); //create insert into php here global $wpdb; $table ='insert_Table_Name'; $data = array ( 'credits' => -$numberofbookings, 'action' => 'transaction', 'user_id' => $current_user ); $wpdb->insert($table,$data); } } } } } ?>
thanks for your reply Just want to ask where does this method go please. does it go in this section
$(document).on("forminator:form:submit:success", function (e, id) { $(document).on("forminator_form_after_save_entry", function (e, id) {
thanks once again for helping me
Hello, I am just posting an updated version of my code, I have got the insert to work but not using the method forminator:form:submit:success instead it was working using the method after.load.forminator which is not what i want. I would like the insert to happen on form submit.
<?php /** *Plugin Name: Forminator Purschase Extenstion *By : Matthias McCarthy *Description: An extenstion for Forminator to insert transactions after submitting a form *Version: 1.0.0 * */ add_action( 'wp_footer', function(){ global $wpdb; $current_user = get_current_user_id(); ?> <script type="text/javascript"> (function ($) { $(function () { $(document).on("forminator:form:submit:success", function (e, id) { if(id === 2001){ var link="<?php echo admin_url('admin-ajax.php')?>"; var dataUID = $(
#forminator-module-${id}
).attr("data-uid"); var numberOfBookings =#forminator-module-${id} #forminator-field-number-1_${dataUID}
; const loggedInUserID =<?php echo json_encode($current_user)?>
console.log(loggedInUserID) console.log($(numberOfBookings).val()) jQuery(document).ready(function($){ $.ajax({ url: link, contentType: "application/json; charset=utf-8", data:{ action:'complete_purchase', userId: loggedInUserID, numberOfBookings: $(numberOfBookings).val() } }); }) } }); }) })(window.jQuery); </script> <?php }, 21); ?>Hi there
thank you for your reply, can you guide me on a way to create custom code like where do I write the code please.