Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
bbPress 1 to bbPress 2 cleanup tool
<?php
/*
Please read the bbPress 1 conversion article on foliovision.com before using
*/
include('wp-load.php');
global $wpdb;
$aPosts = $wpdb->get_results( "SELECT * FROM $wpdb->posts AS p JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type IN ('forum','topic','reply') AND ( meta_key = '_bbp_old_topic_id' ) LIMIT 10000 " );
// Hint: take this from step 2.
$aDeleted = array(1,2,3,4,...);
foreach( $aPosts AS $objPost ) {
$action = false;
if( in_array($objPost->meta_value,$aDeleted) ) {
$action = 'delete';
$wpdb->query( "UPDATE $wpdb->posts SET post_status = 'trash' WHERE ID = '{$objPost->ID}'" );
}
if( $action ) {
echo $objPost->ID.' '.$objPost->post_title.' '.$objPost->meta_value.' '.$objPost->post_status." will be ".$action."\n";
}
}
echo "=====\n\n\n";
// Hint: take this from step 1.
$aModerated = array(1,2,3,4,...);
$aPosts = $wpdb->get_results( "SELECT * FROM $wpdb->posts AS p JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type IN ('forum','topic','reply') AND ( meta_key = '_bbp_post_id' ) ORDER BY meta_value LIMIT 10000 " );
foreach( $aPosts AS $objPost ) {
$action = false;
if( in_array($objPost->meta_value,$aModerated) ) {
$action = 'moderated';
$wpdb->query( "UPDATE $wpdb->posts SET post_status = 'pending' WHERE ID = '{$objPost->ID}'" );
}
if( $action ) {
echo $objPost->ID.' '.$objPost->post_title.' '.$objPost->meta_value.' '.$objPost->post_status." will be ".$action."\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.