Skip to content

Instantly share code, notes, and snippets.

@polevaultweb
Last active August 29, 2015 14:14
Show Gist options
  • Save polevaultweb/d0d27fda7eda47d9f87e to your computer and use it in GitHub Desktop.
Save polevaultweb/d0d27fda7eda47d9f87e to your computer and use it in GitHub Desktop.
Edit profile IDs for WP Migrate DB Pro
<?php
add_action( 'admin_init', 'wpmdb_tweak_profile_id_edit' );
function wpmdb_tweak_profile_id_edit() {
$profile_mappings = array(
2 => 1,
3 => 2,
);
$wpmdb_settings = get_site_option( 'wpmdb_settings' );
$old_profiles = $wpmdb_settings['profiles'];
if ( isset( $old_profiles[0] ) ) {
// already been run, abort
return;
}
$new_profiles = array();
foreach ( $old_profiles as $key => $profile ) {
$id = $key + 1; // the profile ID is always +1 to array key
if ( isset( $profile_mappings[ $id ] ) ) {
$key = $profile_mappings[ $id ] - 1;
}
$new_profiles[$key] = $profile;
}
$wpmdb_settings['profiles'] = $new_profiles;
update_site_option( 'wpmdb_settings', $wpmdb_settings );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment