Problems with $wpdb
-
I’m trying to change some entries in the wpdb, to change the status of reservations in a booking calendar to approved on a successful payment. It doesn’t seem to work, and I really have no clue as to why. I’m pretty new to wordpress, php and javascript, so it’s probably something really silly.
Here’s my code:
Functions.php:
function set_db_transient() { if(isset($_COOKIE['user_key'])){ set_transient($_COOKIE['user_key'] . 'database_id', $_POST['database_id'], 600); } wp_die(); } add_action( 'wp_ajax_set_db_transient', 'set_db_transient' ); add_action( 'wp_ajax_nopriv_set_db_transient', 'set_db_transient' ); function filter_woocommerce_payment_successful_result() { global $wpdb; $change_status = $wpdb->update($wpdb->prefix . 'reservations_table_name', array('status' => "approved"), array('id' => get_transient($_COOKIE['user_key'] . 'database_id'))); }; add_filter( 'woocommerce_payment_complete', 'filter_woocommerce_payment_successful_result');
JS ajax call:
database_id = $("input[name='reservationid']").val(); jQuery.post( 'wp-admin/admin-ajax.php', { 'action': 'set_db_transient', 'database_id': database_id });
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problems with $wpdb’ is closed to new replies.