Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // do something every month
- global $wpdb;
- $evil_author = THE_ID_OF_THE_AUTHOR_WHOSE_POSTS_YOU_WANNA_BUZZIATE;
- $them_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE AND post_author = $evil_author" AND post_type = "my_post_type"); // Replace my_post_type by the post type you want
- foreach ( $them_posts as $post_die )
- {
- wp_delete_post( $post_die->ID, true ); // Bypasses Trash and deletes all the posts
- }
- <?php
- /*
- Plugin Name:My Custom Plugin
- Description:My Custom Plugin
- Version:1.0
- */
- register_activation_hook(__FILE__, 'my_activation');
- function my_activation() {
- if (! wp_next_scheduled ( 'my_monthly_event' )) {
- wp_schedule_event(time(), 'monthly', 'my_monthly_event');
- }
- }
- add_action('my_monthly_event', 'do_this_monthly');
- function do_this_monthly() {
- // do something every month
- global $wpdb;
- $evil_author = THE_ID_OF_THE_AUTHOR_WHOSE_POSTS_YOU_WANNA_BUZZIATE;
- $them_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE AND post_author = $evil_author" AND post_type = "my_post_type"); // Replace my_post_type by the post type you want
- foreach ( $them_posts as $post_die )
- {
- wp_delete_post( $post_die->ID, true ); // Bypasses Trash and deletes all the posts
- }
- }
- // cleaning the scheduler on deactivation:
- register_deactivation_hook(__FILE__, 'my_deactivation');
- function my_deactivation() {
- wp_clear_scheduled_hook('my_monthly_event');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement