一天后自动删除buddypress活动

时间:2014-07-23 06:02:30

标签: sql wordpress buddypress

我一直在使用wordpress插件开发社交网站。活动页面显示了几个用户的活动。我需要的是在一天后删除活动,比如24小时后应从服务器删除活动。有什么方法可以做。请帮助。谢谢!

1 个答案:

答案 0 :(得分:0)

有不同类型的buddypress活动。首先要确定要删除的内容,并确定要删除它们吗? (您可以隐藏/取消发布或限制查询)

关于24小时 - 我将使用cron作业,请参阅:Executing a PHP script with a CRON Job

我们需要在使用SQL的自动化测试过程结束时删除与wordpress帖子相关的活动。也许这会有所帮助:(未经测试)

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);