I have been developing a social site using the wordpress plugin buddypress.The activities of several users are shown in the activity page.what i need is to delete the activities after a day like after 24 hours the activities should be deleted from server.is there any way to do it .please help.thanks!!
Asked
Active
Viewed 460 times
1 Answers
0
There are different types of buddypress activities. First be sure of what you want to delete and are you sure you want to delete them ? (You could just hide / unpublish them or have a way to limit the query)
With regards to 24 hours -I'd use a cron job, see: Executing a PHP script with a CRON Job
We needed to delete activities related to wordpress posts at the end of our automated testing process using SQL. Maybe this helps: (not tested)
DELETE t1 FROM wp_postmeta t1 LEFT JOIN wp_posts t2 ON t1. post_id = t2.ID WHERE post_date IN ($yesterdayandbefore);
DELETE FROM wp_comments t1 LEFT JOIN wp_posts t2 ON t1. comment_post_ID = t2.ID WHERE post_date IN ($yesterdayandbefore);
DELETE FROM wp_posts WHERE post_date IN ($yesterdayandbefore);
DELETE FROM wp_bp_activity WHERE date_recorded IN ($yesterdayandbefore);
DELETE t1 FROM wp_bp_activity_meta t1 LEFT JOIN wp_bp_activity t2 ON t1.activity_id = t2.id WHERE date_recorded IN ($yesterdayandbefore);