New WordPress Plugin — Auto Add Users To Mingle

I downloaded the Mingle Forum Plugin today and started tooling around with it. After working through a number of small configuration problems, I discovered that you have to manually allow users to post in forums. Since the plugin is actually really great, I didn’t want to scrap it despite this missing functionality.

It didn’t seem like it should be “that hard” to figure out the database tables that handled the user-group relationship and create a WordPress plugin that would automatically join a new user to the appropriate tables. I’m not sure why, exactly, I assumed this — but that’s the premise I was working off of. The following is the actual plugin and details for anyone that wants to implement it as-is. There’s plenty more work that would need to be done to “release it”.

It’s important to mention that EVERY user that logs into your WordPress instance will be added to a SINGLE group. There’s no way to exclude any users (without adding code for that explicit purpose). This isn’t a problem for my implementation, but I can understand that this may be an issue for some people. Either way, I’m sure this should be adequate for most people’s use.

Plugin Name: Auto Add Users To Mingle
Plugin URI:
Description: This plugin automatically joins any user to a defined group ID so they can make forum posts
Version: 0.1
Author: Mike Brum
Author URI:
License: Freestuffz

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY. Please test it in a way that will not
expose you to the loss of data if any problems are encountered.

class forumAdder {
function add2forum() {
global $current_user, $wpdb;
$current_user = wp_get_current_user();
$cuid = $current_user->ID;

# check db to see if they’re part of “the group”
$id_query = “SELECT id, user_id FROM wp_mauimtg_forum_usergroup2user WHERE user_id = ‘$cuid’”;
$my_id = $wpdb->get_row($id_query, ARRAY_N);

# if not, then add them
if ( (! $my_id[1] ) && ($cuid != ’0′) && ($cuid != ”) ){
$wpdb->insert( ‘wp_mauimtg_forum_usergroup2user‘,
array( ‘user_id’ => $cuid, ‘group’ => 2 ),
array( ‘%d’, ‘%s’ )

$myForumAdder = new forumAdder();
add_action(‘shutdown’, array($myForumAdder, ‘add2forum’));

So the first thing that you’ll need to do is copy the code above to a file and put it in your plugins dir for WordPress. I called it “auto_add_users_to_mingle.php”. Seemed appropriate.

There’s two things that you need to change:

wp_mauimtg_forum_usergroup2user — this is the Mingle ‘forum_usergroup2user’ table. Given the WordPress table prefix for the blog I was added it to is “wp_mauimtg_”, this is how we get this full table name. If you look in your wp-config.php file and look at your $table_prefix variable, it should be obvious what this should be changed to. It’ll basically be: $table_prefix + ‘forum_usergroup2user’

For reference, my exact line from wp-config.php is:

$table_prefix¬† = ‘wp_mauimtg_’;

The other important thing that needs to change is the line:

array( ‘user_id’ => $cuid, ‘group’ => 2 ),

Specifically, the number “2″ (the rest of the line needs to stay exactly the same).

Now, there’s no “easy” way to figure out what this number is supposed to be. You’re going to have to log into your database and figure out what that number is.

Here’s a straight forward way to figure it out (using the table names that I’m looking at as defined by my $table_prefix):

1) look at all entries in the table wp_mauimtg_forum_usergroups and find the group that you want everyone to be added to. There’s a column called “name” that will actually display the group name, so there’s no real guessing involved once you spit out the contents of wp_mauimtg_forum_usergroups.

2) the value in the “id” column is the number that you’re going to want to specify in the above line.

For example, if you have a group called “Family” that you wanted everyone added to and you looked that row up in your wp_mauimtg_forum_usergroups table and found that it had an id of “15″, then the line would need to be changed to:

array( ‘user_id’ => $cuid, ‘group’ => 15 ),

Once you’ve made the 2x table name changes and the 1x number change, you should be ready to activate the plugin.

If you get an error, you’ve probably screwed up the PHP syntax and should fine-tooth-comb the changes you made.

As I mentioned, this is my first plugin, so I’m sure there’s a number of things I could do to improve it. For instance, I’d imagine there’s a way to pull out the value of $table_prefix and do the string concatenation and I could make an admin panel for the plugin that brings up the list of groups in wp_mauimtg_forum_usergroups and lets you select one from a pull-down instead of having to hack at it by hand.

But both of these enhancements are for another day.

I just wanted to contribute the code if it can help others. Hope you have luck implementing it.

You can download a zip file directly:

Sep 15th, 2011 | Filed under Random

Green Sea Turtle Compilation Video

I’ve been taking video while snorkeling for a little while since I got my GoPro HD Hero. I decided to start actually processing it and put together this compilation of green sea turtles.

It’s “long” (around 10m), but I’ve happily watched it a few times.

As I start taking more video, I’m sure I’ll be posting it more regularly as well.


Sep 4th, 2011 | Filed under Hawaii, Travel, Video

Not Quite 5 Hour Energy

I’m up late tonight with some overnight maintenances for work.

On one hand, it’s only 11pm here because work is pegged to EDT and I’m in HST. The bad thing is that I’m also pretty tied to EDT and wake up at 5am or earlier. If I were still on the East Coast, it’d be 5am and I’d have been up from the night prior, with work starting at 11:30pm. But given that I’m still waking up really early, the fact that it’s only 11pm is somewhat immaterial — especially when you consider how long I’ve been working today. The raw hours are a bit scary.

From my last trip to Oahu, I had a leftover “5 Hour Energy” drink that I never ended up needing. It was the first time I had bought one, but figured since I’d be up really late, it was probably worth having it just in case. Well, ‘in case’ never came so it traveled back with me to sit in my medicine cabinet. Around 8pm, I could tell that I was starting to get a tad slower. I was far from “tired”, but I knew I was going to be feeling it in a few hours despite the copious amounts of Coke that I’ve been consuming all day long. With that realization, I went to the medicine cabinet and cracked open the tiny bottle.

While bringing it to my mouth to drink, I paused and read the “instructions”. Basically, they said “drink half of the bottle if you want 1/2 the energy in the bottle, but drink the whole thing if you want super energy”. I knew I had at least 5-6 hours of work ahead of me, so I figured it was both safe and prudent to go all in.

Here’s where disappointment sets in — it’s only 3 hours later (I’m still working) and I feel exactly like I would have had I not taken that drink. I have to do a lot of out-of-hours work and get woken up in the middle of the night with phone calls, so I’ve got a pretty good bead on how I react to sleep and sleep deprivation.

My loose assumption is that my body is pretty well tuned to break down stimulants given my diet that consists of a large amount of sugar and caffeine sources. I’m one of those people that can drink soda right up to going to bed and my eyes still shut when I hit the pillow. Maybe this should have flavored my expectation of efficacy, but given the explicit goal of the drink, I was hoping for more.

Next time, I’ll just take an afternoon nap.

Aug 30th, 2011 | Filed under Random, Work

Planning A Day In Maui

We’ve been in Maui for about 4 months now. We also just had our first extended visit from friends, which was great. Not only was it really good to see familiar faces from home, it also gave us a lot of experience with helping people plan their time and figure out what to do while they’re here.

I know some people are always going to be content spending endless hours on the beach from sun up to sun down. I’m not one of them. I actually can’t stand just hanging out at the beach. For me, the beach is that sandy place that I have to walk across to get to the water.

What you need to know about Maui is that there’s not a huge night life. If you need dance clubs and the sort of activity you’d find in a city, you’re much better off heading to Waikiki on the island of Oahu. However, if you want to kick back and relax in one of the most beautiful places in the world after a long day of having a great time – this may be exactly where you want to be.

To get the most out of your time, you’re going to want to get up early and start your activities when the sun’s still low in the sky. This has the obvious benefit of being a bit cooler but also the earlier you get out the fewer other people you have to deal with. For popular activities, there can be A LOT of people to contend with and it’s nice to get in and out with as few hassles as possible. You’re typically going to have to make a reservation with the company that you’ll be doing your activity with and you won’t have any idea how many other people are in your group unless they say what their maximum size is. Some snorkel boats can easily pack 50+ people and drop you all off in the same exact place… and a popular spot will see many boats visiting at the same time. I heard one person mention that the popular dive spot Molokini can see over 3,000 people in an average day.

I’m sure a lot of people think that the last thing they want to do on vacation is get up early. I can sympathize. But if you’re coming to Hawaii from the East, you’re already looking at anywhere between a 2 to 7 hour time difference depending on where in North America you’re coming from and the time of year you’re visiting (Hawaii doesn’t follow Daylight Savings Time, so there’s a one hour swing for almost any timezone). So even if you want to sleep in, you’re going to be getting up “early” anyway — so you might as well do something with that time. Plus, if you stay in the routine of getting up early every day on your trip, it’ll make readjusting to your original time zone easier when you finally head home.

With all of this said, you still need to pick what you want to do. Some very obvious choices are:

  • Snorkel trip to Molokini
  • Go kayaking (you can paddle to snorkel spots, anchor and then snorkel right out of the kayaks)
  • Learn to dive or get on a dive trip with one of the local shops if you’re certified (remember your C-card!)
  • Watch the sun rise or set from Haleakala
  • Walk Front St. in Lahaina and do some shopping
  • Hike any of the multiple hikes around the island
  • Drive to Hana
  • Go on a whale watch (in the Winter months only)

With the exception of a trip to Hana (which can fill an entire day) and Haleakala (which will be pegged to sunrise or sunset unless you visit in the middle of the day), most activities are going to let you start early (between 7am and 8am) and last to sometime around lunch. Once you get lunch and possibly clean up, you’ve got the rest of the day to do “something”.

If you want to maximize your time and fill it with “stuff” that’s not necessarily just lounging, then the best formula to follow is to make all appointments that you need to schedule (snorkel or dive trips, kayaking, boat rides, etc) as early in the morning as possible. Then, leave yourself a bit of time for lunch and then plan those activities that don’t require appointments (free snorkeling, shopping, hiking, beach time, etc.) for afternoon until sunset. The vast majority of planned activities you end up doing tend to last only about half a day and keeping this in mind really helps plan out your time.

I understand that many people aren’t big planners, but even these people are going to want to try to plan things out for a few days when it comes to activities that require reservations. You’d be surprised how quickly various trips and events can fill up. A small amount of planning can ensure that you’ll get to do everything that you want.

Aug 26th, 2011 | Filed under Hawaii, Travel

Shark Week — Long Time Listener, First Time Caller

I’ve been a HUGE fan of Shark Week for years. I remember catching it for the first time in the late 80′s, which would have been one of the first years that Shark Week aired. Given that I would have been between 10 and 12 at the time, I don’t remember exactly what year it was. What I do remember is how absolutely enthralled I was with all the high quality shark content.

Whenever possible, I made it a point to dedicate hours in the middle of summer sitting in from of the TV when Shark Week rolled around. The only thing that kept me from watching it was if we didn’t have cable at the time.

It wasn’t too long before phrases like “lateral lines“, “tonic immobility” and “Ampullae of Lorenzini” became familiar instead of novel and obscure. While this is a clear sign that the education aspect of Discovery’s mandate is working, it also shows that there’s a lot of repetition in the content. Given how expensive it can be to produce good content — let alone good content on the water or hundreds of feet beneath the surface — there is obvious a certain degree of give and take to be expected.

We just have to accept that there’s going to be a certain amount of repetition in the content as well as multiple shows utilizing the same file footage of the random interesting rare thing that’s only been captured by one submarine at 2,000 feet that one time. We get it and we’re forgiving. Plus, if there’s an incredibly cool clip that we get to see a bunch of times, most of us will just enjoy the engaging rerun.

That all said, here’s where my complaint surfaces — it appears that at least 50% of all of the Shark Week content all revolves around The Great White and there’s very little new content being produced for it.

Before I dig any further, I want to say that I love white sharks. Absolutely every single thing about them is incredible and mind blowing and it’s great to see them getting positive press now and again.

With that out of the way, the main problem that I see with Discovery’s coverage is that there’s very little new science coming out about white sharks these days. The content mostly switches back and forth from “don’t look like a seal or turtle” and “most attacks are mistaken identity” and “blahblahblah rogue shark”. Then, seemingly out of nowhere, we got the Air Jaws phenomena and now every time we see a white shark introduced it’s a 16-footer that’s at least half out of the water, trying to eat a rubber seal and traveling in such slow motion that Pam Anderson would even embarrass to be seen in. Now don’t get me wrong — the first time I watched white sharks breach, I was completely captivated and locked to my TV. But at this point, how much new content is really being produced? The programs that Shark Week runs aren’t even 100% new material. We have many programs airing in prime time slots that have been shown all year long.

It all boils down to this: Discovery, if you’re going to dedicate such a HUGE percentage of¬† your coverage to such a narrow portion of all possible topics that “shark week” could entail, then you need to generate new and captivating content to air.

While there’s a need for the occasional high-drama show like Air Jaws now and again, that documentary was still a great balance of action and scientific content. When the show ended, I felt both entertained and informed — which is the exact formula that I think all Discovery programs should strive for. The problem is that those of us that want to learn something are being hedged out by content that’s catering to those that want to see crazy great whites do crazy shark things. It feels like the only really solid scientific content I see on Shark Week comes from the reruns that I’ve already seen from years past.

My suggestion to you, Discovery, is to put more money into research and write checks to those scientists that are in the field without camera crews. The documentary expeditions that you do are great, but it’s only part of the puzzle. It’s the boring lab work and tedious field work that nobody wants to see that ultimately breeds the sort of content that makes a great program. Given this, we need to reward these people by supporting their work directly — and being a huge benefactor of their work, it’s only fair for you to contribute more and contribute directly to it.

I don’t need another animated Megalodon special. I don’t want Mythbusters or Mike Rowe as hosts. Give me real science. I want to learn something again. I want my Shark Week back.

Aug 2nd, 2011 | Filed under Bitching

Molokini Crater & Turtle Town Snorkel Trip

Took a trip to Molokini Crater yesterday and did some snorkeling. It was a great time and I got a few nice photos. There’s a small series that I haven’t processed and published yet since they’re pretty specific and very cool, so I want to handle them separately and make a separate post about them. Expect them within a day or two.

You can head over to my Underwater Photo Gallery for the 9 new images that I added.

Quick G12 Update:

Overall, I was VERY happy with the G12 in the Canon WP-DC34 waterproof case for the G12. There are two small issues that I have with it:

  1. The “half press” on the shutter button to focus simply doesn’t give enough response through the waterproof case to know if you’ve successfully half-pressed it.

    When you do succeed, there’s usually a visual queue on the LCD, but this can be easy to miss both by not noticing it or by going straight past that and fully depressing the button.

    It’s possible that this will get sorted out as the housing gets “broken in” more — but it’s annoying to miss shots due to it.

  2. I shoot A LOT in AV mode (aperture priority) mode – especially underwater. The dial in the front to let you set your aperture doesn’t have an exposed dial on the underwater housing. This means that you can’t change your aperture in AV mode after it’s already set.

    I don’t know if there’s another way to change it, but I haven’t found it. I’ll keep looking, but the fact that this one dial doesn’t have an exposed dial in the housing is very unfortunate.

But those two quibbles aside, I was both happy with how it performed and the photos that it took. Hopefully the shortcomings won’t be impossible to work around.

Jul 31st, 2011 | Filed under Hawaii, Photography

New Camera Time — Canon PowerShot G12

My Canon PowerShot A710-IS is pretty much dying. Let me rephrase that: the camera is still in GREAT shape and takes great pictures, but the camera just burns through fresh batteries in about a half hour. The fact that the images it takes are still great is the only shame.

Despite owning a Canon 30D (which I use for my more “serious” underwater photography) and a Canon 5D mkII (which I use for almost everything else), I like keeping a point and shoot for situations when I don’t want to take all my gear — be it because I don’t want to take a bag with me to carry the camera or because we’re going to be snorkeling and my full underwater rig is 100% overkill.

Up until recently, the A710-IS has performed those duties very well. And when faced with the decision of what to replace it with, the Canon G12 quickly rose to the top of the list.

Even though I’ve only had it for about 2 days, here’s what I like about the G12:

  • It can be used as a “real” camera with consideration given to manual settings
  • All the options for those manual settings are very easy to access (many P&S cameras do have manual settings – but they’re VERY hard to get to making them almost unusable)
  • The tilt & swivel LCD is really nice
  • Natively shoots RAW without any wonky firmware hacks
  • There’s a hot shoe (yes, this is awesome)
  • The visual readout on the LCD is great – with lots of current settings displayed, a level and a histogram
  • It takes a battery pack instead of a bunch of AA’s (some people like AA’s for the flexibility)

There are a few things that I don’t like, but most of them are very minor:

  • The tripod mount isn’t centered over the lens (it’s centered relative to the camera body)
  • The on-cam flash casts a shadow on close objects from the lens (not uncommon for many P&S cams)
  • The G12 RAW files aren’t able to be read w/ CS4 – you need to upgrade to CS5 (not really a Canon problem, but worth mentioning)

Most of the images that I’ve taken have been just shooting around the house to get familiar w/ the camera. The real test will come tomorrow when I take the G12 out on a long snorkel trip.

If there are any good photos or if I run into any problems, I’m sure I’ll be posting about them soon.

Jul 29th, 2011 | Filed under Photography

Galleries Are Fixed Now — NextGEN Gallery Not Displaying Thickbox Images

After laying down for bed, I had an epiphany last night and got up and based away at the keyboard for a bit. Luckily, the effort wasn’t wasted, as I was able to fix the issue that caused the problem in the first place.

The long story boiled down is that the ThickBox can find a “group” of images if you pass it common name in the rel param in your a tag. For instance:

That’s simple enough. Any link that has the rel param set to “anyString” will be shown with Thickbox having “next” and “prev” links so you don’t have to view, close, open the next by hand. Very handy feature, for sure!

However, if the rel param happens to have a space in it, this appears to break completely, resulting in the image not being displayed. I’m sure there’s some degree of bug on Thickbox’s side, but I decided to fix it on the NextGEN Gallery side since that’s code I’m far more familiar with.

The fix is rather simple. In /wp-content/plugins/nextgen-gallery/lib/image.php, find the line:

function get_thumbcode($galleryname = ”) {

Immediately under that, add the following two lines:

 // Fix thickbox failure when $galleryname has a space in it
$galleryname = preg_replace( ‘/\s+/’, ”, $galleryname );

And that’s it. That strips the whitespace from the $galleryname variable which is what’s passed on to the code that populates the rel param in image links for Thickbox.

Just keep in mind that if you make this change on your server, your changes will be overwritten when you perform your next update — so make a note and be sure to apply this fix again after you upgrade.

Jul 27th, 2011 | Filed under Nerd, Photography, Site News

WP Is Pissing Me Off

I updated WP to the latest version on 7/15. Since then, my image gallery hasn’t been working properly. Specifically, the Thickbox display effect simply doesn’t load the image. No idea why.

In the meantime, I’ve disabled the Thickbox display until I can figure out why.

…I’m really annoyed.

Jul 27th, 2011 | Filed under Photography, Site News

A Magical Weekend In Oahu

I spent last Friday through Sunday on Oahu. It’s the first time I’ve been on Oahu since 2005. Despite this, I wasn’t there for sightseeing, I was there to play Magic — as in, Magic: the Gathering.

Yes – that means that I boarded an airplane and flew through the air in order to play a card game.

I don’t tend to talk about Magic that much, mainly keeping the chatter isolated to my twitter feed, but it’s something that I used to fill a lot of my free time with before moving. I was regularly playing a couple times a week in organized events back in Boston. Unfortunately, there is zero organized play on Maui. We don’t even have a game store here. As such, the only options are to either find people to play with (I’ve found a couple, and they’re few and far between) or go somewhere else to play.

Luckily, Oahu has a pretty big Magic community and it’s really close. From wheels up to wheels down, I timed our flight as 20 minutes. They list the trip as a 40m flight, but that’s to take into account the time pulling away from the gate before actually taking off and all the taxiing after landing. Also thankfully, my credit card accrues Hawaiian Air miles, so the flight itself is “free” – leaving just the hotel to pay for.

It might be a bit extreme, but it’s something that I really enjoy and only will end up doing this maybe 3-4 times a year at most. That’s quite a far cry from playing 2 or more times a week.

At the end of the day, the lack of Magic players is really the only thing that I have to complain about with Maui. And if that’s all I have to complain about, I’m probably doing really well.

Jul 16th, 2011 | Filed under Hawaii, Magic: the Gathering, Travel