[wp-hackers] Remove useless usermeta

Edward de Leau e at leau.net
Sun Oct 31 20:00:31 UTC 2010

this is related to this topic "remove useless metadata":

If you remove users it will not remove (all) this metadata in the metadata
user field. this includes wp_capabilities and wp_usermedata entries and
entries made by plugins in this table for these users.

that in itself is not a problem... but in the GUI of the users the COUNTER
counts on the basis of unique entries of users in the metadata table and not
the user table meaning.... you can delete a lot of users but the counter you
see there  in the gui will never
go down even if the user itself no longer exists in the user table.

So... "remove useless metadata" (also for the user counter in the "users"

On Fri, Oct 8, 2010 at 5:20 AM, Mike Schinkel
<mikeschinkel at newclarity.net>wrote:

> 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.
> -Mike
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

More information about the wp-hackers mailing list