How to run SQL query from WordPress ‘WP Crontrol’ plugin

I managed to get things working by using: include_once(“wp-config.php”); include_once(“wp-includes/wp-db.php”); global $wpdb; $sql = “UPDATE wp_pmpro_memberships_users SET wp_pmpro_memberships_users.status=”admin_cancelled” WHERE wp_pmpro_memberships_users.user_id IN ( /*Select all users that have an active Membership but no active Subscription*/ SELECT pmpro.user_id FROM wp_pmpro_memberships_users as pmpro JOIN wp_pmpro_membership_levels as pmprol ON pmprol.id=pmpro.membership_id JOIN wp_users ON pmpro.user_id = wp_users.ID WHERE pmpro.status=”active” AND … Read more

Insert NULL value using prepare()

the quick solution I found is to str_replace empty value. /* Query */ global $wpdb; $tablename = $wpdb->prefix . ‘data’; $sql = $wpdb->prepare( ” UPDATE $tablename SET `date` = %s, WHERE id= %d “, $_POST[‘date’], $_POST[‘id’] ); // SQL = UPDATE prefix_data SET `date` = ” WHERE id = 1 $sql = str_replace(“””,’NULL’, $sql); // … Read more

Join Query on WP_USERMETA Table

function get_users_email ($time_zone_cont, $class_group){ // Add Lisa’s user id, 14, in an array. $exclude_list = array( ); $Time_Zone = $time_zone_cont; $user_class_group = $class_group; $args = array( // ‘role’ => ‘Editor’, // ‘exclude’ => $exclude_list, ‘meta_query’ => array( // ‘relation’ => ‘OR’, array( ‘key’ => ‘Time_Zone’, ‘value’ => $Time_Zone, ‘compare’ => ‘=’ ), array( ‘key’ => … Read more