Delete anonymus users mu-plugin not working?
-
Hello,
So i am “blessed” with the anonymous users created in wp_users and wp_usermeta (this particular WP setup is highly customized).
I found this but i don’t think the function is triggered at all// Remove users and meta data. function fix_wpsc_clear_customer_meta_andre() { echo "TEST wpsc clear function"; wp_mail('[email protected]','WPSC delete users','function been called'); exit(); global $wpdb; require_once( ABSPATH . 'wp-admin/includes/user.php' ); $purge_count = 200; $sql = " SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key = '_wpsc_last_active' AND meta_value < UNIX_TIMESTAMP() - " . WPSC_CUSTOMER_DATA_EXPIRATION . " LIMIT {$purge_count} "; // Do this in batches of 200 to avoid memory issues when there are too many // anonymous users. @set_time_limit( 0 ); // no time limit do { $ids = $wpdb->get_col( $sql ); $included_ids = array(); foreach ( $ids as $id ) { $included_ids[$id] = $id; } $in = implode(',', $included_ids); $wpdb->query("DELETE FROM $wpdb->users WHERE ID IN ($in)" ); $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id IN ($in)"); } while ( count( $ids ) == $purge_count ); // Update number of users. $tmp_total_users = count_users(); /*echo 'test: '.$tmp_total_users; exit();*/ update_option('user_count', $tmp_total_users['total_users'] ); } function fix_reset_wpsc_cron_andre() { remove_action( 'wpsc_hourly_cron_task', '_wpsc_clear_customer_meta' ); add_action( 'wpsc_hourly_cron_task', 'fix_wpsc_clear_customer_meta_andre' ); }i add this test bit
function fix_wpsc_clear_customer_meta_andre() { echo "TEST wpsc clear function"; wp_mail('[email protected]','WPSC delete users','function been called'); exit();and in wp-config i have set WPSC_CUSTOMER_DATA_EXPIRATION to 1 minute
define( 'WPSC_CUSTOMER_DATA_EXPIRATION', 60 );But i don’t receive an email, so how can i check if add_action wpsc_hourly_cron_task is valid?
The topic ‘Delete anonymus users mu-plugin not working?’ is closed to new replies.