Advertisement
Guest User

Untitled

a guest
Dec 28th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. function ResetVote($postids, $action) {
  2. /*
  3. Testing stuff...
  4. echo 'Posts: '.implode(', ',$_POST['post']);
  5. echo '<br />';
  6. echo "Action: ".$action;
  7. */
  8. global $wpdb;
  9. //$wpdb->show_errors();
  10.  
  11. switch ($action) {
  12.  
  13. case 'none':
  14. //do nothing
  15. break;
  16. case 'delete':
  17. //reset all votes for the post
  18. $i = 0;
  19. while ($i < count($postids)) {
  20. $wpdb->query("UPDATE ".$wpdb->prefix."votes SET votes = '',guests = '',usersinks = '', guestsinks = '' WHERE `post`=".$postids[$i]." LIMIT 1 ;");
  21. $post_id = $postids[$i];
  22. update_post_meta($post_id, '_votemecount', 0);
  23. $i++;
  24.  
  25. }
  26. EditVoteSuccess();
  27. break;
  28. case 'deleteuser':
  29. //reset all votes for users
  30. $i = 0;
  31. while ($i < count($postids)) {
  32. $wpdb->query("UPDATE ".$wpdb->prefix."votes SET votes = '',usersinks = '' WHERE post=".$postids[$i]." LIMIT 1 ;");
  33. $i++;
  34. }
  35. EditVoteSuccess();
  36. break;
  37. case 'deleteguest':
  38. //reset all votes for guests
  39. $i = 0;
  40. while ($i < count($postids)) {
  41. $wpdb->query("UPDATE ".$wpdb->prefix."votes SET guests = '',guestsinks = '' WHERE post=".$postids[$i]." LIMIT 1 ;");
  42. $i++;
  43. }
  44. EditVoteSuccess();
  45. break;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement