Advertisement
erodemobiles

global.php

May 2nd, 2011
577
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.63 KB | None | 0 0
  1. function myplugin_activate()
  2. {
  3.     global $wpdb;
  4.    
  5.     $q = "UPDATE {$wpdb->comments} SET user_id = '0'";
  6.     $wpdb->query( $q );
  7.    
  8.     $query = "SELECT DISTINCT $wpdb->comments.comment_author, wp_users.ID FROM $wpdb->comments INNER JOIN wp_users ON ($wpdb->comments.comment_author = wp_users.display_name)";
  9.     $comments_with_user = $wpdb->get_results( $query,  ARRAY_A );
  10.     foreach( $comments_with_user as $key => $value )
  11.     {
  12.         $q = "UPDATE {$wpdb->comments} SET user_id = {$value['ID']} WHERE comment_author = '{$value['comment_author']}'";        
  13.         $wpdb->query( $q );        
  14.     }
  15.  
  16.     return TRUE;  
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement