OpenID 3.3.3 & WordPress 2.9.x

Sunday, August 29th, 2010 by Tobias in Online, PHP

Today was WordPress maintenance Sunday for me. I sorted out all the spam Akismet hadn’t caught and updated a few of the plugins we are using with WordPress. However I hadn’t enough time to update WordPress itself to version 3.0.1. So we are still running 2.9.2. This caused some trouble when I was upgrading the OpenID plugin to its latest version 3.3.3. Accessing the WordPress admin panel I got stuck with an PHP error reading

Call to undefined function get_user_meta()

WordPress codex tells us this function get_user_meta is not available in WordPress until version 3.0. It is replacing the now deprecated function get_usermeta which is available for earlier versions of WordPress. So I came up with a little hack to get the OpenID plugin running again for my ancient 2.9.2 version of WordPress.

Simply add these lines at the top of the plugin files admin_panels.php, server.php and server_ext.php:

/**
* Hotfix for WordPress 2.x
*/
if ( !function_exists('get_user_meta') ) {
function get_user_meta($user_id, $key, $single = false) {
if ( $single == false )
return array(get_usermeta($user_id, $key));
else
return get_usermeta($user_id, $key);
}
}

This code defines a new function get_user_meta in case it is not existing already. The new function calls the deprecated function get_usermeta and returns the result so the plugin is working as expected again.



Recently

Fast Lane Music

Thursday, May 27th, 2010 by Tobias in Music

Fullsizing

Sunday, May 16th, 2010 by Tobias in Chrysler 300 Hurst

Numb3rs

Sunday, May 9th, 2010 by Tobias in Chrysler 300 Hurst

Jesus Stole My Girlfriend

Monday, April 5th, 2010 by Tobias in Music

Colloquial

Sunday, April 4th, 2010 by Tobias in Uncategorized

8 Miles A Gallon

Saturday, April 3rd, 2010 by Tobias in Cars, Music

Like Christmas

Wednesday, December 30th, 2009 by Tobias in Photos