Recently I had cause to retrieve a list of customer emails (which due to guest checkout functionality is not the same as a list of user emails) from a WooCommerce installation. A quick search suggested that the easiest way was to install a plugin to do the job. I hate installing plugins on WordPress unless absolutely necessary (as half of them, including this one, are very badly maintained and thus either a security risk, a performance risk, or both).
Instead, the SQL query to retrieve this information, as well as a count of how many orders each customer has made, took only a few minutes to prepare and run:
As you might have noticed, I’ve switched back to using WordPress (again), and managed to dig up all my old blog posts (most of which are utter crap). At the moment I’m using the lighttpd web server, and I had to play around a bit with mod_rewrite in order to get the pretty URLs working. In the end I got lazy and just settled for a hack I found on the Internet. And as a hack, it’s pretty epic.
server.error-handler-404 = "/index.php?error=404"
What it does is thus: when you click on a page in the blog (such as http://www.jackscott.id.au/2009/04/hack-of-the-year), it searches for a folder named 2009 on my web server. That doesn’t exist, so it produces an HTTP 404 error (which means the page doesn’t exist). The rule above (pasted into the lighttpd configuration file) redirects all 404 errors to the index.php file. And this file (as the WordPress main file) just happens to know where to find the page requested. Truly a monumental hack.
The only downside to using this configuration is that Statpress (my favourite WordPress plugin) no longer works properly. It reports the correct number of page views and so on, but all pages requested are listed as ‘error=404‘. Not very useful when you want to see which pages are viewed the most.
But nevertheless, a pretty cool thing.