Well it looks like it’s a WP issue.
I installed a fresh WP and followed steps to enable multisite.
I created 2 sites: the main one called “Site-1” (wp_site id=1) and a second one called “Site-2” (wp_site id=2).
I manually created two custom taxonomies via a simple plugin:
<?php
/*
Plugin Name: Test Custom Taxonomy WPMU
*/
function registerTaxonomy() {
$blogId = get_current_blog_id();
$taxonomyName = "Custom Taxonomy $blogId";
$taxonomySlug = "custom-taxonomy-$blogId";
// create a new taxonomy
register_taxonomy(
$taxonomySlug,
'post',
array(
'label' => $taxonomyName,
'rewrite' => array( 'slug' => $taxonomySlug ),
)
);
}
add_action( 'init', 'registerTaxonomy' );
?>
and then created a script to test the term insert on customer taxonomy 2 on site 2:
<?php
#specify host or domain (needed for wp-includes/ms-settings.php:100)
$_SERVER[ 'HTTP_HOST' ] = 'test.local';
#location of wp-load.php so we have access to database and $wpdb object
$wp_load_loc = "/var/www/test/wp-load.php";
require_once($wp_load_loc);
switch_to_blog(2);
$o = wp_insert_term( "Test for CT 2", 'custom-taxonomy-2');
print_r($o);
?>
and still getting error.
Moreover if I do a term insert on customer taxonomy 1 – that is NOT defined in site2 – i can see that site2 db has the entry in the wp_2_term_taxonomy, and that does not make sense.
I guess I will open the bug somewhere for WP dev community, unless I’m missing something since I’m not so into WP dev & logic.