User ID is not saving to the database with $wpdb->insert()
-
I have noticed that the user id is not saving to the database in 4.8. For example this section of code works fine in 4.7 but comes up null for $user_ID in 4.8:
global $wpdb; $user = wp_get_current_user(); $user_ID = $user->ID; . . . $wpdb->insert(wp_cartpauj_pm_messages, array( 'from_user' => 1, 'to_user' => $user_ID, 'last_sender' => 1, 'date' => current_time( 'mysql' ), 'last_date' => current_time( 'mysql' ), 'message_title' => 'Treatment Consent', 'message_contents' => "Attached is your copy of your signed treatment consent. The Notice of Privacy Practices is available at this link: [url=https://www.testurl.pdf]Notice of Privacy Practices[/url]. Please down load both documents and save for your records.", 'message_read' => 0, 'to_del' => 0, 'from_del' => 0 ), array('%d', '%d', '%d', '%s', '%s', '%s', '%s', '%d', '%d', '%d')); $message_id = $wpdb->insert_id; $wpdb->insert(wp_cartpauj_pm_attachments, array( 'message_id' => $message_id, 'filename' => $filename, 'mimetype' => 'application/pdf', 'contents' => $contents ), array('%d', '%s', '%s', '%s'));
$user_ID will work in other parts of my code, for example to insert into my pdf but it will not save to database. The same is true for CFDB. No user ID is saving there either. I understand that it is a CFDB issue. Complaints have been made on that forum. Nevertheless, for my code, I would like to be able to save some things to database with the $user_ID. What may be a work around?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘User ID is not saving to the database with $wpdb->insert()’ is closed to new replies.