Over the years my website has gathered loads of usermeta data that I would like to selectively delete - best with an SQL query - however I don’t know how (yet).
Here are the fields I would like to delete (if I find out I will post how)
For all users remove the following meta_key entries - which is easy:
DELETE FROM wp_usermeta WHERE meta_key = ‘aim’;
DELETE FROM wp_usermeta WHERE meta_key = ‘rich_editing’;
DELETE FROM wp_usermeta WHERE meta_key = ‘show_admin_bar_front’;
DELETE FROM wp_usermeta WHERE meta_key = ‘locale’;
DELETE FROM wp_usermeta WHERE meta_key = ‘jabber’;
DELETE FROM wp_usermeta WHERE meta_key = ‘default_password_nag’;
DELETE FROM wp_usermeta WHERE meta_key = ‘wfls-last-login’;
DELETE FROM wp_usermeta WHERE meta_key = ‘wp_s2member_file_download_access_log’;
DELETE FROM wp_usermeta WHERE meta_key = ‘wp_s2member_file_download_access_arc’;
DELETE FROM wp_usermeta WHERE meta_key = ‘yim’;
DELETE FROM wp_usermeta WHERE meta_key = ‘syntax_highlighting’;
DELETE FROM wp_usermeta WHERE meta_key = ‘comment_shortcuts’;
DELETE FROM wp_usermeta WHERE meta_key = ‘admin_color’;
DELETE FROM wp_usermeta WHERE meta_key = ‘use_ssl’;
DELETE FROM wp_usermeta WHERE meta_key = ‘wp_user_level’;
DELETE FROM wp_usermeta WHERE meta_key = ‘_tern_wp_member_list’;
DELETE FROM wp_usermeta WHERE meta_key = ‘wp_s2member_last_auto_eot_time’;
DELETE FROM wp_usermeta WHERE meta_key = ‘crb_reg’;
However For subscribers: wp_capabilities = a:1:{s:10:“subscriber”;b:1;}
I would like to drop the following entries on top:
wp_s2member_paid_registration_times
wp_s2member_first_payment_txn_id
wp_s2member_ipn_signup_vars
wp_s2member_last_login_time
wp_s2member_login_counter
wp_s2member_last_auto_eot_time
My usermeta table is over 200 MB in size, so I really would like to cut it down to make the database faster and especially make backups via email easier.
Also actually all maybe even delete all subscribers who have not logged in for XX years (wp_s2member_last_login_time ) whould be a good idea GDPR wise.