SQL query to delete comments older than 90 days?

Regarding comments- what about the case where a comment older than 90 days has child replies younger than 90 days? for comment and pingback status, this should do it: UPDATE wp_posts SET comment_status=”closed”, ping_status=”closed” WHERE post_date < DATE_SUB(NOW(), INTERVAL 3 MONTH) AND post_status=”publish”;

Update some database fields when post is saved

Best way for storing them is WordPress’ Options Mechanism. ANd best way to trigger it when a post saved is using WordPress save_post action. Example : add_action( ‘save_post’, ‘count’ ); //Execute count() when a post saved/updated function count() { your codes here … //save them to DB update_option(“lines-of-code”, $lines); update_option(“disk-space”, $diskspace); … }

wp_insert_user is not working for me?

The problem is from wp_insert_user and the fact that your value for user_pass is empty. You should update your code as so $random_password = wp_generate_password(8,false); $user_data = array( ‘user_login’ => $first_name, ‘user_pass’ => $random_password, ‘user_email’ => $trainer_email, ‘first_name’ => $first_name, ‘last_name’ => $last_name, ‘role’ => ‘trainer’ ); And remove this line wp_set_password($random_password, $user_id); You should … Read more