Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function myplugin_activate()
- {
- global $wpdb;
- $q = "UPDATE {$wpdb->comments} SET user_id = '0'";
- $wpdb->query( $q );
- $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)";
- $comments_with_user = $wpdb->get_results( $query, ARRAY_A );
- foreach( $comments_with_user as $key => $value )
- {
- $q = "UPDATE {$wpdb->comments} SET user_id = {$value['ID']} WHERE comment_author = '{$value['comment_author']}'";
- $wpdb->query( $q );
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement