The following lines of code both store the IP address and time of vote,
// $ip holds $_SERVER['REMOTE_ADDR']
$voted_IP[$ip] = time();
// Save IP and increase votes count
update_post_meta($post_id, "voted_IP", $voted_IP);
The time a vote is cast is already being stored for you in the post_meta
table for the given post the person is voting on.
To retrieve the votes and corresponding times for a given post you can do this,
$mykey_values = get_post_custom_values('voted_IP', $post_id);
foreach ( $mykey_values as $key => $value ) {
echo "$key => $value <br />";
}
That would return a list in a similar format to,
192.166.342.8 => 1349260674
202.646.100.3 => 1349260674
^ IP numbers ^ unix time stamps
Related Posts:
- 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
- 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
- Use ajax from function.php
- Ajax return code 400
- wp_insert_post() is returning the correct post ID, no failure, but the post content does not get updated
- doing an ajax request always outputs 0
- How to test nonce with AJAX – Plugin development
- Woocommerce add to cart quantity buttons with AJAX
- Ajax result show in console if is called outside function and not showing in array
- 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
- How can i send id of the currently posted form data through json response in custom wordpress plugin?
- 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”
- defined (‘ABSPATH’) false after AJAX post to other PHP-file
- Find the method which AJAX GET calls
- AJAX Filter WHILE Loop not working WordPress
- 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
- 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
- Pass a PHP variable (loop-audio.php) to jQuery function (js/script.js)
- 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
- 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