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.


english
deutsch