add_filter( 'woocommerce_new_customer_data', 'my_custom_user_data'); function my_custom_user_data( $new_customer_data ) { …
Disallow spaces in WordPress usernames
add_filter( 'validate_username', 'my_no_space_username', 10, 2 ); /** * Checks to see if a username contains whitespace. * @see: …
MySQL delete records in one table that do not exist in another table
DELETE FROM content_to_tags WHERE NOT EXISTS ( SELECT * FROM content WHERE content_id = content_to_tags.content_id ) …
MySQL update column in one table with data from another table
update table1 t1 join table2 t2 on t2.field = t1.field set t1.field1 = t2.matchingfield where t1.whatever = t2.whatever …
MySQL copy table data to a new table
CREATE TABLE backup_table LIKE existing_table; INSERT backup_table SELECT * FROM existing_table; …
Get all WordPress user emails
$users = get_users(); foreach ( $users as $user ) { $email = $user->user_email; } …
Find duplicates values in a MySQL table
SELECT col, COUNT(col) FROM table_name GROUP BY col HAVING COUNT(col) > 1; …
Delete orphaned post meta in WordPress database
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL …