-
-
Save boonebgorges/14c0d1042e85d263d48f3eaf7ca25b6d to your computer and use it in GitHub Desktop.
force migration of BPGES 3.9 data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'admin_init', | |
function() { | |
global $wpdb, $bp; | |
if ( ! current_user_can( 'manage_options' ) ) { | |
return; | |
} | |
if ( empty( $_GET['bpges-force-migrate'] ) ) { | |
return; | |
} | |
$migrate_type = wp_unslash( $_GET['bpges-force-migrate'] ); | |
switch ( $migrate_type ) { | |
case 'subscriptions' : | |
$group_ids = $wpdb->get_col( "SELECT gm.group_id FROM {$bp->groups->table_name_groupmeta} gm LEFT JOIN {$bp->groups->table_name_groupmeta} gm2 ON ( gm.group_id = gm2.group_id AND gm2.meta_key = '_ges_subscriptions_migrated' ) WHERE gm.meta_key = 'ass_subscribed_users' AND gm.meta_value IS NOT NULL AND gm2.meta_value IS NULL" ); | |
echo '<pre>'; | |
foreach ( $group_ids as $group_id ) { | |
echo "Migrating group $group_id\n"; | |
bpges_39_migrate_group_subscriptions( $group_id ); | |
} | |
echo '</pre>'; | |
echo "\n"; | |
echo "Migration complete."; | |
bp_update_option( '_ges_39_subscriptions_migrated', '1' ); | |
die; | |
break; | |
case 'queued_items' : | |
$user_ids = $wpdb->get_col( "SELECT um.user_id FROM {$wpdb->usermeta} um LEFT JOIN {$wpdb->usermeta} um1 ON ( um.user_id = um1.user_id AND um1.meta_key = '_ges_digest_queue_migrated' ) WHERE um.meta_key = 'ass_digest_items' AND um.meta_value IS NOT NULL AND um1.meta_value IS NULL" ); | |
echo '<pre>'; | |
foreach ( $user_ids as $user_id ) { | |
echo "Migrating user $user_id\n"; | |
bpges_39_migrate_user_queued_items( $user_id ); | |
} | |
echo '</pre>'; | |
echo "\n"; | |
echo "Migration complete."; | |
bp_update_option( '_ges_39_digest_queue_migrated', '1' ); | |
die; | |
break; | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment