From an example in the Developer Reference:
To get the id of the inserted object use
$wpdb->insert_id;
global $wpdb; $table = $wpdb->prefix.'you_table_name'; $data = array('column1' => 'data one', 'column2' => 123); $format = array('%s','%d'); $wpdb->insert($table,$data,$format); $my_id = $wpdb->insert_id;
Related Posts:
- AJAX Filter WHILE Loop not working WordPress
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- How can I fetch loop of post titles via AJAX?
- Retrieve POST data from AJAX call
- Do I require the use of nonce?
- WordPress Ajax always returns a 404 error
- problem with ajax and the path to the php page
- How to use wp_localize_script in a WordPress page other than functions.php?
- Real time Duplicate title check
- Passing JSON data from WP Query into AJAX causing NULL errors
- Load custom field value into div with AJAX
- Security – Ajax and Nonce use [closed]
- Jquery ajax to custom php file: returning blank data
- Update WordPress Custom Field with AJAX on cached page
- Looking for a better way to handle an ajax script that pulls in post data on click
- Targeting single page with JS
- Can’t use get_results() in ajax query
- Problem with WordPress Ajax form
- Click loads template via ajax
- Display notification only once
- How to retrieve the content (with a specific ID) via ajax by clicking a link tag
- Access/update database with jQuery
- How to display something in a div when the user clicks on a text in another div – no page refresh [closed]
- Passing jQuery value using Ajax to a page template
- ajax_object is not defined when ajax calls the function
- How to speed up admin-ajax.php in wordpress
- Returning a value from a PHP page
- Why is this Ajax not working?
- Stumped – Ajax Response Returns 0
- Colorbox ajax loading of outside HTML content works perfect on localhost but not on server
- Sending jsPDF documents to the server
- Ajax result show in console if is called outside function and not showing in array
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- Ajax filter with loadmore button
- Admin-ajax.php 404 error
- Where to add my PHP codes for AJAX Jquery to work?
- How to pass values from one function to the other using an array variable
- How to change PHP variables with AJAX request in WordPress
- How to use wp_ajax_set_post_thumbnail?
- Update $wpdb query with AJAX
- Can’t make lazy load for my site, help!
- How to reload a php script, using AJAX and jQuery
- wp_ajax_ 400 Bad Request
- AJAX to add to cart multiple products woocommerce
- update_post_meta Not Processing Array Data (Not Sure What I Am Missing)
- wp_set_object_terms returns 500 error when called through AJAX function
- Cannot successfully execute AJAX script to call function.php specific function. Using XAMPP localhost to test
- WordPress ajax filter returning all posts when it should be filtering by category
- Input field duplicates on form submit by jQuery
- How to echo a PHP code into WooCommerce variation product?
- How can i get the same ajax result using WP REST API instead of admin-ajax?
- How to call a function from functions.php with ajax?
- Custom theme admin-ajax.php 400 (Bad Request)
- Remove item from post_meta array via AJAX
- number of posts with “Load More”
- wp_send_json erase last value
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Find the method which AJAX GET calls
- Ajax not updating to database
- WordPress 404 when using AJAX to call php function
- wordpress ajax pagination
- WordPress AJAX load post metadata in modal
- how use php query in AJAX jquery
- Ajax Load more CPT via shortcode
- Why I’m Not Having Access to “$_POST” Data Outside My AJAX Callback?
- Submitting my form to the database and then redirecting to payment site
- Pass the updated value of aid from form using ajax
- ajax form with multiple submit buttons and values
- Result from wp_send_json adds line feed
- How to run ajax in WordPress Post?
- 500 (Internal Server Error) of external php file
- Use jQuery and AJAX to get HTML
- Adding instant search to wordpress page
- Add php function into .js file (for tinyMCE button)
- Dynamic Gallery
- best way to communicate between php and jquery/javascript
- Loading a post’s content, into a div outside the loop, when it’s title is selected in a list
- Fatal error: Uncaught Error: Call to undefined function wp_nav_menu()
- ajax form function error
- AJAX: WordPress filters inside $html do not work as intended
- Why not showing all post by default in my jquery filter
- Load Meta box value into div AJAX [duplicate]
- Jquery autosave text area after typing
- JSON Object Value Show Undefine
- notify users when changed database
- getJSON response to PHP
- ajax problems on loading page [closed]
- Upload multiple files via ajax from an HTML file input
- Help with AJAX request
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- custom AJAX filtering logic and outputting results into an Elementor Loop Grid widget
- Help with uploading file with AJAX and PHP
- Help with creating commenting system using PHP, jQuery and AJAX
- Update shortcode values using ajax call
- Woocommerce – how can i add items to cart using onclick – multiple items at once with custom prices
- ajax select parent show child in another select and show posts in another select-ajax filter search
- Add/Remove User Meta Array via AJAX
- How do I ensure that the URL parameters are updated correctly when multiple filters are applied
- Filtered queries not responeding to page path