My network is showing roles in some sites and not in others.
For some reason that I can’t explain, when I add a new user, I have no roles to choose from in the drop down box of a sub-site in my network. Also, my new user assigned to a site is not showing on my list of users for that site.
Is this something fixable?
Below an image of the current situation.
Below is the picture showing the main site with the roles properly there, but the sub-sites of the network don’t.
wp_##_options
(wp_99_options) â you will have a table for each blogoption_name
=wp_user_roles
wp_user_roles
towp_##_user_roles
(“wp_99_user_roles”)The table you are editing will have
option_id
,blog_id
,option_name
,option_value
,autoload
. However, DO NOT CHANGE ANY RECORD except the record whereoption_name
=wp_user_roles
. There will only be a single record in this table like this.wp_user_roles
is used when there is no Multisite install, and here, it appears as though it was just a bug when the table was created.I had this problem with a Multisite installation after reinstalling WordPress and restoring from an Updraft Plus backup.
When I checked the
user_roles
record, the option_name was still set to the original four character prefix, such aspre1_user_roles
, whereas the prefix for the second installation was something likepre2_user_roles
.I updated this to
pre2_user_roles
and the options immediately reappeared in the user options page.If this is the problem I know so well, you are running a memcache setup behind your MU install? I’ve found that there’s apparently a cache issue (witnessed in 2.9) for the options object where something good (like the wp_user_roles key) gets stuck in the “notoptions” memcache array.
If you do run atop memcache, and this sounds like a possiblity, try telnetting into the machine via 11211. Type
delete blogid:options:notoptions
, where the blogid is the id of the blog on which you see the issue. Refresh the admin panel and see if there are roles in the dropdown. If so, you’ve found your problem.UPDATE: OK, so you did not find your problem — you weren’t running memcache. I would still check out the roles object, looking for a corrupt or non-existant one. I believe it’s your best lead. You can use this code to dump the options table:
THANK YOU. This issue represents a solid 10 hours of debugging. This was a real bear for me.
To expand on this a bit, I added a function to my site that will allow you to resolve this issue if you’re creating sites programmatically.
Basically, this will check to see if
wp_user_roles
was set in the specified blog. If it is, the function will usewp_user_roles
to set a new option in the correct manner.I just wanted to say thank you for this article because I’ve been searching for a solution to this problem for a long time.
It was simply because I had used a plugin to clone my sites and it never updated the
wp_##_user_roles
properly. When the site copied over fromwp_13...
it was cloned over to a new sitewp_81...
but this entry was still stuck atwp_13
.I just want to point out that some people may still have an empty site users tableâspecifically for their root site. If this problem occurs, the way to fix it issue is by doing the following:
I believe “1” is always the ID of the root site.
Cheers.
Install this plugin: https://wordpress.org/plugins/capability-manager-enhanced/
Go into your site > Capabilities > Settings > Backup > Reset Roles, click “Reset to WordPress Defaults” and it will fix your site.
Nothing else worked for me.