// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
$caps =
get_user_meta( $user->ID,
$wpdb->prefix . 'capabilities'
);
if ( empty( $caps ) ||
defined( 'RESET_CAPS'
) ) { $level =
get_user_meta( $user->ID,
$wpdb->prefix . 'user_level', true
);
$role =
translate_level_to_role( $level );
update_user_meta( $user->ID,
$wpdb->prefix . 'capabilities', array
( $role => true
) );
} endforeach;
$old_user_fields = array
( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level'
);
$wpdb->
hide_errors();
foreach ( $old_user_fields as $old ) { $wpdb->
query( "ALTER TABLE
$wpdb->users DROP
$old"
);
} $wpdb->
show_errors();
// Populate comment_count field of posts table.
$comments =
$wpdb->
get_results( "SELECT comment_post_ID, COUNT(*) as c FROM
$wpdb->comments WHERE comment_approved = '1' GROUP BY comment_post_ID"
);
if ( is_array( $comments ) ) { foreach ( $comments as $comment ) { $wpdb->
update( $wpdb->posts, array
( 'comment_count' =>
$comment->c
), array
( 'ID' =>
$comment->comment_post_ID
) );
} }