WordPress user editing problems

I am playing with “Your Members” again and deactivated it to get some clean screenshots of one of my plugins –  I was bemused to discover that this error had not been fixed in wordpress (It is now milestoned for 3.1 some future release.)

Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string

The cause is that one deactivates a plugin that had stored some object data in the usermeta table (where it should, rather than creating new tables).  However if it creates it’s own object (and why should it not?) then if the code is not around to read that object this message occurs and you cannot save your user data!

The problem in my view is a wordpress one.

There is a patch which is ‘old’, but for some reason not applied to wp 3.0. The quick fix is to apply the patch. So for 3.01, wp-includes/functions.php lines 1458 to 1469

Replace this:

function add_magic_quotes( $array ) { 
global $wpdb; 
foreach ( (array) $array as $k => $v ) { 
if ( is_array( $v ) ) { 
$array[$k] = add_magic_quotes( $v ); } 
else { $array[$k] = $wpdb->escape( $v ); } } 
return $array; }

With this:


function add_magic_quotes( $array ) { 
global $wpdb; 
  if ( is_array($array) ) { 
    foreach ( $array as $k => $v ) { 
      $array[$k] = add_magic_quotes( $v ); 
    } 
   } 
  elseif ( is_string($array) ) { 
      $array = $wpdb->escape( $array ); 
  } 
  return $array; }

If you do not like editing (and re-editing after each upgrade until 3.1!) then the longer answer as I have noted before, AND assuming you do not need the data anymore,  is to remove the user-meta that was created by the plugin (You’d need phpmyadmin).

In the DB, in the user-meta table, find all the meta keys that belong to the deactivated plugin and delete them for all your users!