Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ResetVote($postids, $action) {
- /*
- Testing stuff...
- echo 'Posts: '.implode(', ',$_POST['post']);
- echo '<br />';
- echo "Action: ".$action;
- */
- global $wpdb;
- //$wpdb->show_errors();
- switch ($action) {
- case 'none':
- //do nothing
- break;
- case 'delete':
- //reset all votes for the post
- $i = 0;
- while ($i < count($postids)) {
- $wpdb->query("UPDATE ".$wpdb->prefix."votes SET votes = '',guests = '',usersinks = '', guestsinks = '' WHERE `post`=".$postids[$i]." LIMIT 1 ;");
- $post_id = $postids[$i];
- update_post_meta($post_id, '_votemecount', 0);
- $i++;
- }
- EditVoteSuccess();
- break;
- case 'deleteuser':
- //reset all votes for users
- $i = 0;
- while ($i < count($postids)) {
- $wpdb->query("UPDATE ".$wpdb->prefix."votes SET votes = '',usersinks = '' WHERE post=".$postids[$i]." LIMIT 1 ;");
- $i++;
- }
- EditVoteSuccess();
- break;
- case 'deleteguest':
- //reset all votes for guests
- $i = 0;
- while ($i < count($postids)) {
- $wpdb->query("UPDATE ".$wpdb->prefix."votes SET guests = '',guestsinks = '' WHERE post=".$postids[$i]." LIMIT 1 ;");
- $i++;
- }
- EditVoteSuccess();
- break;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement