Import settings from another theme

Well, you can read the core code to find the actions, or you can use a debugging method to find the one you need.

Put into wp-config.php:

define('WP_DEBUG', true);
define( 'WP_DEBUG_LOG', true );

Then make a mu-plugin file containing:

<?php 
add_action( 'all', '_action_printer' );
function _action_printer( $a ){
    if (strpos('gettext', $a) === false && strpos('escape', $a) === false) {
      $x = func_get_args();
      $x = print_r($x, true);
      error_log( $x .  "\n", 3, dirname(__FILE__). '/../debug.log');
    }

}

This will output the arguments to all the actions to the debug.log file in the wp-content folder, so it will get big fast and slow down your site. (I removed two since they are used a lot.) Use it just long enough to capture the actions for what you need, which is switching themes in the Customizer. Or just print the action name ($a) instead for a smaller output.

Once you have the list of actions, you can amend your code to hook to the appropriate action. You may have to check is_customize_preview() to make sure the code is run at the right time. Be aware that the user can preview lots of themes without actually choosing to use one, so your theme really should not be writing to the database when in the Customizer (because it’s just a preview).