Website Cleanup – Delete Drupal Users who have no ubercart orders

  • Home
  • /
  • Blog
  • /
  • Website Cleanup – Delete Drupal Users who have no ubercart orders

June 24, 2014

Migrating Cousin Rob’s www.DRUMSTHEWORD.com website from his 6 year old Drupal6 website to a new (hopefully sexier) WordPress4 website has meant a lot of data cleansing before golive. Before we get any comments about Drupal vs. WordPress, or a CMS flamewar, the new website was chosen to be on WordPress because of WOOCOMMERCE and a neat WordPress Theme that had already been selected.

So, I’m going to leave a little blog about any particular problems I found, or cool tricks I found, during data migration.

The old drupal website had over 48,000 users defined… many of them spam… many of them dead… many redundant or no longer needed.

So how do we cleanup users?

Using the PHP panel I used this SQL script to select the users that have been registered but who have never ordered anything using Drupal6 Ubercart:

select count(*) from users where mail not in 
(select primary_email from uc_orders) and
 uid <> '0' and
 mail NOT LIKE "%drumstheword.com%" and
 mail NOT LIKE "%projex%"

note: do not touch uid=0 because this is the ANONYMOUS user and do not touch any *@drumstheword.com or *@projex.com users

This will give you a count value showing how many users are selected and if your ready to delete then just use:

delete from users where mail not in
(select primary_email from uc_orders) and
 uid <> '0' and
 mail NOT LIKE "%drumstheword.com%" and
 mail NOT LIKE "%projex%"

*boom*

NickLitten


IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Shameless Trekkie, Belligerent Nerd, Englishman Abroad and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and remember: If at first you don't succeed then skydiving probably isn't a hobby you should look into.

Nick Litten

related posts:

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Start your
7-day free trial

Take This Course with ALL ACCESS

Unlock your Learning Potential with instant access to every course and all new courses as they are released.
 [ For Serious Software Developers only ]

IBM i Training For Technology Experts

New!

Successfully Work Remote 

 $ 129.00  $59.00

By adding new skills in information technology, employers will be confident that you have the necessary skills and tools needed to successfully work remotely

>

Snug CBD

 20% Discount

I have partnered with SNUG CBD givING you Organic CBD
20% discount code "NL20"