Skip to content

Playing With Code

Every now and then, I find I miss programming. This isn’t to say that I miss the corporate programming environment, cause wow, I really do not! But getting my brain churning on solving a problem and fiddling with code until it does what I want? Yeah, I miss that.

So, when I was chatting with Valerie Comer, one of the admins on the InspyRomance blog and she mentioned the headache that drawing our monthly comment winner is. See, over there on InspyRomance, every comment on every post is entered into a monthly $30 gift card drawing. (Did you know that? If not…now you do! Now come on over and hang out with us!) And Valerie has been going through the posts for each month by hand and making a spreadsheet and then culling out the ineligible comments (like from those of us who blog there) and then using random.org to pull the winner. Needless to say, it takes a looong time.

Being techier than the average cat, I figured there had to be a way to automate it. After all, WordPress is just a big database, how hard could it be? Step one? Figure out if anyone else had already done it. Cause, really, why reinvent the wheel? There are a ton of plugins for choosing a comment winner on just one post. But I didn’t find any that would let you include multiple posts. I poked around many of them, and decided I liked the look of Pick Giveaway Winner the best. And so, I grabbed the source code and poked through it.

Technically, I don’t know PHP. But…it’s easy enough to read and figure out given the languages I *do* know. And SQL, well I love it. So a few hours later, I’d played around and added the functionality to choose a date range instead of just a particular post, and exclude users of the site as well as any other specific email addresses that get entered (cause with our guest posts over there, the visiting author will usually comment and we need to exclude them, as well.) And…I’m so pleased with how it turned out.

More than that? It was fun to play around with code again. It’s been too long.

Back To Top
Privacy Policy

Cookie Policy