Add menu items/actions for multisite users who are registered on the network but do not have a role or capability in any sites
We’ve built a custom application (Pressbooks) that sits on top of WordPress multisite and transforms the multisite into a CMS for book publishing. A frequent flow for super admins is to invite a new user onto the network without adding them to a specific site. Let’s call these users ‘lowly users’ because they’re registered on the network but don’t have a role in any of the network sites. Typically, our multisite users should be able to create new sites (book) OR use a custom ‘cloning’ routine to copy an openly licensed book/site from another Pressbooks to a newly registered site on their network via API.
Right now, lowly users can create a new site/book (using
wp-signup.php), but the cloning routine is only accessible from the dashboard of an existing site on the network. This means that ‘lowly users’ can’t use the cloning routine until they have a role in an existing site/book. We’d like to figure out a way to allow these lowly users to access and use the cloning routine (https://github.com/pressbooks/pressbooks/issues/1899).
Our first thought was make the cloning routine a sub page of the user profile page, which is visible for new users, rather than connecting it to a specific site/book. The problem we’re facing is that it appears WordPress’
add_menu_page or similar all require a capability argument (https://developer.wordpress.org/reference/functions/add_menu_page/) for the user, and these ‘lowly users’ don’t have any capabilities or roles in any sites. Users can however edit their profile and access the
wp-signup.php file to create a new book.
Is there a way to register a sub-page of
user/profile.php that these lowly users can access? Can we register our own action for
wp-login.php that would let users clone books?
Should we hook into
user_register (https://developer.wordpress.org/reference/hooks/user_register/) and automatically give lowly users a role/capability (like subscriber) in the root site when they’re first added to the network? Other ideas?