Select User by Joining Multiple Meta Value Results

Try this one with additional join on metadata SELECT u.ID, u.display_name FROM wp_users u LEFT JOIN wp_usermeta um1 ON u.ID = um1.user_id LEFT JOIN wp_usermeta um2 ON u.ID = um2.user_id WHERE um1.meta_value=”value1″ AND um1.meta_key = ‘key1’ AND um2.meta_key = ‘keyA’ AND um2.meta_value=”valueA” GROUP BY u.ID Also use group by

Different database query in function.php using mysqli

Since version 3.9 (that will be released soon, actually in beta 2) WordPress will use mysqli to connect to database (3.9- versions use mysql) so you can actually use new wpdb instances and helper function to connect externa values from WordPress. What I suggest is to configure external database using constants in wp-config.php in this … Read more

wpdb insert and boolean fields

BOOL or BOOLEAN are as far as MYSQL is concerned just replacements/synonyms for TINYINT(1), tiny integer, so using %d for integers is the correct way to do it. Some additional information: Codex: Class Reference – wpdb – Placeholders MySQL: Numeric Type Overview MySQL: Boolean Literals MySQL: Integer Types

WP_USE_EXT_MYSQL

This constant is actually never defined in core code at all. You can define it yourself in wp-config.php configuration if you need to, but core doesn’t need it defined for normal operation. It only exists for re–configuring into running untypical setup.

What SQL / WordPress queries would need a nonce?

You might be a little confused as to the purpose and function of nonces in WordPress. Recommended reading: WordPress Nonces An Introduction to WordPress Nonces with Examples Protect_Queries_Against_SQL_Injection_Attacks A nonce is a “number used once” to help protect URLs and forms from certain types of misuse, malicious or otherwise. Nonces help you ensure, somewhat, the … Read more

Manually removing revision post types

IF you want, you can disable revisions in first place (No need to run CRON then) To disable them go to wp-config.php and add this line: define(‘WP_POST_REVISIONS’, false ); Or to limit to 10 revisions define(‘WP_POST_REVISIONS’, 10); And to delete all current revisions you can run this SQL query: DELETE FROM wp_posts WHERE post_type = … Read more

How to Create a Admin User for A WordPress Site via MySQL (PHPMyAdmin)?

You need to run those below queries- INSERT INTO `your-wp-database`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `display_name`) VALUES (‘1000’, ‘your_username’, MD5(‘Str0ngPa55!’), ‘your_username’, ‘[email protected]’, ‘0’, ‘User Display Name’); INSERT INTO `your-wp-database`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, ‘1000’, ‘wp_capabilities’, ‘a:1:{s:13:”administrator”;b:1;}’); INSERT INTO `your-wp-database`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, ‘1000’, ‘wp_user_level’, ’10’); But notice here your-wp-database … Read more

How to bulk delete all WordPress subscribers?

I ended up deleting all users who had not made a post using the following two queries: First: DELETE FROM wp_users WHERE ID NOT IN (SELECT post_author FROM wp_posts) Second: DELETE FROM wp_usermeta WHERE user_id NOT IN (SELECT ID FROM wp_users)