admin管理员组文章数量:1287125
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.
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.
Share Improve this question edited May 30, 2017 at 10:27 user6003 asked Mar 11, 2011 at 0:05 GeoGeo 7471 gold badge9 silver badges18 bronze badges 07 Answers
Reset to default 33- Determine your Multisite Blog ID. I will use 99 as an example
- Go into the database
- Go to this table:
wp_##_options
(wp_99_options) — you will have a table for each blog - Find the record where
option_name
=wp_user_roles
- Change the text
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 where option_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 as pre1_user_roles
, whereas the prefix for the second installation was something like pre2_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:
global $wpdb;
$array = $wpdb->get_col("SELECT option_name FROM $wpdb->options");
foreach ($array as $key) {
echo $key . ": <code>";
var_dump(get_option($key), true));
echo "</code><br/>";
}
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 use wp_user_roles
to set a new option in the correct manner.
/**
* Sometimes, user roles do not properly get set when a new site is set up
* To fix this issue, we check to make sure the data is added properly and update if not
* See https://wordpress.stackexchange/questions/11725/why-are-my-roles-not-visible-in-a-multi-site-network
*/
function maybeAddUserRoles($blog_id){
switch_to_blog($blog_id);
if(get_option('wp_user_roles')){
update_option('wp_'.$blog_id.'_user_roles', get_option('wp_user_roles'));
delete_option('wp_user_roles');
}
restore_current_blog();
}
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 from wp_13...
it was cloned over to a new site wp_81...
but this entry was still stuck at wp_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:
- Go to the table wp_usermeta
- Find any entries with the meta_key wp_capabilities
- Change the meta_key from wp_capabilities to wp_1_capabilities
I believe "1" is always the ID of the root site.
Cheers.
Install this plugin: https://wordpress/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.
本文标签: multisiteWhy are my roles not visible in a MultisiteNetwork
版权声明:本文标题:multisite - Why are my roles not visible in a Multi-siteNetwork? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741234961a2362828.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论