I have been tugging my hair out for 2 days on that one, any help could be really appreciated.

I am using Wordpress multisite 3.2.

On the website front-end I've got a tool that utilizes wordpress_place_term to include a brand new category to any of the multisite blogs (Im using switch_to_blog() just in case that means something).

I am then calling wordpress_set_object_terms() to include a publish towards the new category produced.

These two work fine, the brand new category will get produced and also the publish will get switched to that particular category.

The Issue:

The permalink for that publish within the new category throws a 404 error. The publish doesn't get put into the Publish Count for that new category.

These two problems could be resolved by:

A) Visit wordpress-admin -> configurations -> permalinks and save permalinks B) Visit wordpress-admin -> posts -> groups -> and add every other category

The above mentioned two solutions will not work with me when i can't by hand do that each time a person uses the tool we built.

What we should have attempted:

function flush_permalinks() {
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%postname%/');
}
add_action('init', 'flush_permalinks');

// This doesn't solve it

We've also attempted:

function flush_permalinks() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
add_action('init', 'flush_permalinks');

// This doesn't solve it

And that we have attempted:

add_action( 'init', 'create_initial_taxonomies', 0 ); 

//This doesn't solve it.

Thanks ahead of time for just about any help or pointing us within the right direction for any solution!

Have you try the template_redirect action rather than init

Yes, it run's before init does.

function flush_permalinks() {
    global $wp_rewrite;
    $wp_rewrite->set_permalink_structure('/%postname%/');
}
add_action('template_redirect', 'flush_permalinks');

Hope that can help,

Nick