• Resolved ljelewis

    (@ljelewis)


    I use the User Role Editor plugin to add custom roles to my sites. I’d hoped that the cloner would copy plugin options belonging to the template site into the new site, but that didn’t seem to be the case, at least for the URE role, when I tried it out.

    The User Role Editor plugin edits the wp_user_roles option on a per site basis. When I look in the DB tables of the cloned sites, I can see the wp_user_roles option is there (named wpx_user_roles, where x is the site ID), but the value is a copy of the option in the main wp_options table, not the wpx_options table of the template site.

    Is this by design and is there any way it can be overridden?

    https://wordpress.org/plugins/multisite-cloner/

    p.s. Apart from this one detail, your plugin works really nicely so far! Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Manuel Razzari

    (@manuelrazzari)

    > 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.

    Thread Starter ljelewis

    (@ljelewis)

    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.

    Plugin Author Manuel Razzari

    (@manuelrazzari)

    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);
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Copy options from template site’ is closed to new replies.