// Blocks access to /wp-admin/ for any user without the identified capability (edit_options=administrator) add_action( 'init', …
Delete orphaned post meta
DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL …
Get a list of orphaned post meta
SELECT * FROM wp_postmeta pm LEFT JOIN wp_posts wp ON wp.ID = pm.post_id WHERE wp.ID IS NULL …
Get email domain from a user’s email
// Verbose example to show steps: $user_email = "example@domain.com"; $email_array = explode( "@", $user_email ); $email_domain = …
Restrict all site access to a specific IP address
add_action( 'init', function() { $ip = ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) ? $_SERVER['HTTP_CLIENT_IP'] : …
Override the WP random password generator with custom generator
// Override the WP random password generator with a custom random password. add_filter( 'random_password', 'my_random_password' ); …
Get user role
/** * Gets WordPress user role. * * @see: https://core.trac.wordpress.org/ticket/22624 * @see: …
Promote your RSS feed on every post
/* * This demo uses the_content filter to add an RSS * link to the end of every post. * * @uses the_content * @uses is_single() …
MySQL UPDATE and REPLACE
UPDATE wp_posts SET post_content = REPLACE( post_content, 'http://mysite.com', 'https://mysite.com' ), guid = REPLACE( guid, …