> the value is a copy of the option in the main wp_options table, not the wpx_options table of the template site.
This isn’t possible, as we’re copying the entire options table as-is.
Then we run this query:
UPDATE wp_NEW-ID_options SET option_name = 'wp_NEW-ID_user_roles' WHERE option_name = 'wp_OLD-id_user_roles';
That’s all we do.
It’s not possible that we’re copying from the main wp_options table.
If you need to add any custom code after a blog is cloned, you can use this filter:
add_action( 'wpmu_new_blog', 'after_set_new_blog'), 2, 1);
And create an after_set_new_blog
callback function with your custom code. The first argument to that function will be the ID of the new blog.
Thanks for your quick reply.
Ok I’ve figured out what’s happening. You’re right, you plugin does copy the wp_user_roles option from the template site to the new site. The problem is that the User Role Editor plugin also adds an action to wpmu_new_blog, with a default priority of 10. The User Role Editor action runs after your action as your action has a priority of 1, and so overwrites the wp_user_roles option with the value from the main wp_options table.
Is there any possibility of increasing the priority of your plugin’s action to make sure it runs last and is not overwritten by other plugins’ actions? If not then no worries, I will write a custom action to rewrite the user roles option.
I wouldn’t dare to change the Cloner’s priority, as it may have side-effects for users with other plugins.
But you could try un-registering our hook, and then re-adding it with a different priority.
Somethings like this (haven’t tested it) in your functions.php:
remove_action( 'wpmu_new_blog', array(MultiSiteCloner, 'set_new_blog')
add_action( 'wpmu_new_blog', array(MultiSiteCloner, 'set_new_blog'), 100, 1);