[wp-hackers] Remove useless usermeta

Mike Schinkel mikeschinkel at newclarity.net
Fri Oct 8 03:20:26 UTC 2010

On Oct 7, 2010, at 10:29 PM, Alex Hempton-Smith wrote:
> Is there an easy way I can remove useless user meta from the wp_usermeta
> table, and stop it from being put there for new signups?
> Almost all of our users have no need for data like 'rich_editing',
> 'comment_shortcuts', 'admin_color', 'aim', 'yim' or 'jabber'.
> I've already disabled the 'aim', 'yim' and 'jabber' contact fields, so these
> aren't being created now. However, I think WordPress should only create the
> other mentioned fields if the user has the capability to edit posts or
> moderate comments. It's creating two unnecessary usermeta entries for each
> user.
> In the meantime, is there a filter I can use to stop this usermeta from
> being created at user creation? And then perhaps only be set if the user
> explicitly sets that option in the admin panel?

This SQL will get rid of them using this SQL:

DELETE FROM wp_usermeta 
WHERE AND meta_key IN ('rich_editing','comment_shortcuts', 'admin_color', 'aim', 'yim', 'jabber') 
AND TRIM(IFNULL(meta_value,''))=''

Then you can either "update_user_meta" to delete right after inserted (since there is not a direct way to abort the insert) or you can try the "query" hook using regular expressions to match the appropriate replace "INSERT {$wpdb->usermeta} SET..." queries with something benign like "SELECT 0".

Hope this helps.


More information about the wp-hackers mailing list