Here is my challenge. I have a plugin installed at the Network level. Its purpose is to add users and roles across the network based on the change in roles from a specific site on the network. Since roles are only managed at the site level, the plugin goes in and adds users and roles to the other sites as needed for our business objectives. I've just finished this plugin and it is working wonderfully well.

However, on one site (Site A), there are other plugins that have specific functions that I would like to automate when a new user role is created on that site (Site A). The challenge is that when the action is initiated at the other site (Site B) or at a network level, the site specific functions (Site A) are not registered.

I'm wondering how I would invoke a function on Site A, when a new user is being registered on Site B. It would seem like I some how need to get Site A to spin up recognize the plugins and their functions that are only registered on Site A.

I know this is a little more obscure functionality of WordPress, any thoughts out there on how to achieve this?

See also: Multisite functions to communicate with individual site functions

1 Answer 1


Instead of relying on switch_to_blog or reaching into the site from the root blog/elsewhere, consider instead using a queue/job system. This way you don't limit the max number of sites you can have based on how many sites PHP can get through before the time execution limit.

In order to do this, you're going to need a way to store the details of the job to be done ( assign role X to user Y ), as well as a cron job that runs regularly that can pick it up.

This way, the cron job runs in the context of the site, not the root blog, allowing you to use filters that plugins can hook into, specific to that site.

I would recommend using a custom post type to store the job entries, deleting the posts as the work is done by the cron job. This also gives you a free pending job list if you give declare the post type as 'public' => false but give it a UI anyway

  • Thanks Tom! I was going in the direction of relying upon a cron job for this. I just found this: core.trac.wordpress.org/ticket/14941, which explains why I can't access plugins from another site. I hadn't considered using a CPT to store the request. That may be a little overkill. I'm thinking that I might add an extra user_meta field that the cron job can look for on Site A. Same principle as what you're suggesting here. Thanks for the help!
    – Brent
    Commented Mar 13, 2018 at 17:24
  • 2
    Note that searching for user/post meta is expensive/slow, I'd strongly advise against it. CPT code can be generated by plugging a few values into a site and copy pasting what the generator gives you, it really is much simpler than user meta
    – Tom J Nowell
    Commented Mar 13, 2018 at 17:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.