Jeremy, your comment makes me wonder if the wp_
vs wp_1_
distinction is part of why certain members of our team occasionally lose their roles on the main site. It could be that bbPress is hardcoding a wp_
check on multisite. See #8860 and related tickets.
I'm typically in the "let's not mess with it", but the fact that there are conflicting values for these permissions in the database suggests to me that there are latent bugs here, and it might be worth the effort to clear it up.
Here's the list of usermeta keys from the production site:
mysql> select distinct meta_key from wp_usermeta where meta_key like 'wp\_1\_%';
+-----------------------------------------+
| meta_key |
+-----------------------------------------+
| wp_1_autosave_draft_ids |
| wp_1_capabilities |
| wp_1_classic-editor-settings |
| wp_1_dashboard_quick_press_last_post_id |
| wp_1_media_library_mode |
| wp_1_persisted_preferences |
| wp_1_s2_authors |
| wp_1_s2_autosub |
| wp_1_s2_cat1 |
| wp_1_s2_format |
| wp_1_s2_subscribed |
| wp_1_user-settings |
| wp_1_user-settings-time |
| wp_1_usersettings |
| wp_1_usersettingstime |
| wp_1_user_level |
| wp_1_yoast_notifications |
| wp_1__bbp_engagements |
| wp_1__bbp_favorites |
| wp_1__bbp_last_posted |
| wp_1__bbp_reply_count |
| wp_1__bbp_subscriptions |
| wp_1__bbp_topic_count |
+-----------------------------------------+
23 rows in set (0.06 sec)
On our current configuration, most users don't have or need to have any caps on the main site. Yet most users have this meta key:
mysql> select count(*) from wp_usermeta where meta_key = 'wp_1_capabilities';
+----------+
| count(*) |
+----------+
| 34747 |
+----------+
1 row in set (0.03 sec)
Here are the distinct values for that key:
mysql> select distinct meta_value from wp_usermeta where meta_key = 'wp_1_capabilities';
+--------------------------------------------------------------------------------------+
| meta_value |
+--------------------------------------------------------------------------------------+
| a:2:{s:6:"author";b:1;s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} |
| a:1:{s:10:"subscriber";b:1;} |
| a:3:{s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;s:14:"courses_editor";b:1;} |
| a:3:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";s:1:"1";s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"subscriber";s:1:"1";s:15:"bbp_participant";b:1;} |
| a:1:{s:13:"administrator";b:1;} |
| a:1:{s:10:"subscriber";s:1:"1";} |
| a:1:{s:15:"bbp_participant";b:1;} |
| a:3:{s:10:"subscriber";s:1:"1";s:10:"can_runPHP";s:0:"";s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"subscriber";s:1:"1";s:10:"can_runPHP";s:0:"";} |
| a:2:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";s:1:"1";} |
| a:3:{s:10:"can_runPHP";b:0;s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";b:1;} |
| a:3:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"can_runPHP";b:0;s:10:"subscriber";b:1;} |
| a:1:{s:10:"can_runPHP";s:0:"";} |
| a:2:{s:6:"editor";s:1:"1";s:15:"bbp_participant";b:1;} |
| a:2:{s:10:"can_runPHP";s:4:"true";s:15:"bbp_participant";b:1;} |
| a:0:{} |
| a:1:{s:6:"author";b:1;} |
| a:2:{s:15:"bbp_participant";b:1;s:10:"can_runPHP";b:0;} |
| a:2:{s:6:"editor";b:1;s:15:"bbp_participant";b:1;} |
| a:2:{s:13:"administrator";b:1;s:13:"bbp_keymaster";b:1;} |
+--------------------------------------------------------------------------------------+
24 rows in set (0.31 sec)
The vast majority of these are either "subscriber" or "bbp_participant". For the sake of bbPress, these users probably need to continue to have their permissions:
mysql> select meta_value, count(*) from wp_usermeta where meta_key = 'wp_1_capabilities' group by meta_value;
+--------------------------------------------------------------------------------------+----------+
| meta_value | count(*) |
+--------------------------------------------------------------------------------------+----------+
| a:0:{} | 777 |
| a:1:{s:10:"can_runPHP";s:0:"";} | 5 |
| a:1:{s:10:"subscriber";b:1;} | 5993 |
| a:1:{s:10:"subscriber";s:1:"1";} | 264 |
| a:1:{s:13:"administrator";b:1;} | 3 |
| a:1:{s:15:"bbp_participant";b:1;} | 20661 |
| a:1:{s:6:"author";b:1;} | 3 |
| a:2:{s:10:"can_runPHP";b:0;s:10:"subscriber";b:1;} | 1 |
| a:2:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";b:1;} | 1 |
| a:2:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";s:1:"1";} | 1 |
| a:2:{s:10:"can_runPHP";s:4:"true";s:15:"bbp_participant";b:1;} | 1 |
| a:2:{s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} | 6925 |
| a:2:{s:10:"subscriber";s:1:"1";s:10:"can_runPHP";s:0:"";} | 7 |
| a:2:{s:10:"subscriber";s:1:"1";s:15:"bbp_participant";b:1;} | 78 |
| a:2:{s:13:"administrator";b:1;s:13:"bbp_keymaster";b:1;} | 1 |
| a:2:{s:15:"bbp_participant";b:1;s:10:"can_runPHP";b:0;} | 5 |
| a:2:{s:6:"author";b:1;s:15:"bbp_participant";b:1;} | 8 |
| a:2:{s:6:"editor";b:1;s:15:"bbp_participant";b:1;} | 1 |
| a:2:{s:6:"editor";s:1:"1";s:15:"bbp_participant";b:1;} | 1 |
| a:3:{s:10:"can_runPHP";b:0;s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} | 1 |
| a:3:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} | 3 |
| a:3:{s:10:"can_runPHP";s:0:"";s:10:"subscriber";s:1:"1";s:15:"bbp_participant";b:1;} | 3 |
| a:3:{s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;s:14:"courses_editor";b:1;} | 1 |
| a:3:{s:10:"subscriber";s:1:"1";s:10:"can_runPHP";s:0:"";s:15:"bbp_participant";b:1;} | 3 |
+--------------------------------------------------------------------------------------+----------+
24 rows in set (0.50 sec)
Interestingly, there's only 240 users on the production site with wp_capabilities
. Only a handful are not 'subscriber':
mysql> select meta_value, count(*) from wp_usermeta where meta_key = 'wp_capabilities' group by meta_value;
+------------------------------------------------------------+----------+
| meta_value | count(*) |
+------------------------------------------------------------+----------+
| a:1:{s:10:"subscriber";b:1;} | 232 |
| a:1:{s:13:"administrator";b:1;} | 3 |
| a:1:{s:15:"bbp_participant";b:1;} | 3 |
| a:2:{s:10:"subscriber";b:1;s:15:"bbp_participant";b:1;} | 1 |
| a:2:{s:13:"administrator";b:1;s:15:"bbp_participant";b:1;} | 1 |
+------------------------------------------------------------+----------+
5 rows in set (0.14 sec)
Given the fact that relatively few users would have conflicting values, I think it's probably do-able to do the necessary merge.
Here's the beginning of an action plan:
0. Back up wp_usermeta and wp_1_ tables
1. Dealing with capabilities
a. Look at the 8 user accounts from my last query who have non-Subscriber values for 'wp_capabilities' and determine what should be done with them.
b. Delete all instances of 'wp_capabilities'
c. Rename all instances of 'wp_1_capabilities' to 'wp_capabilities'
2. Change the rest of the 'wp_1_' keys in wp_usermeta to their 'wp_' equivalents. I'd like to script this rather than doing it manually or trying to run a single replace query.
3. In 'wp_1_options', change 'wp_1_user_roles' to 'wp_user_roles'
4. Change all 'wp_1_' tables to their 'wp_' equivalents. I'd like to script this rather than doing it manually or trying to run a single query for it.
5. Set the MULTISITE flag.
Does that largely cover it? If so, I can try doing it locally before we set up a time to test on cdev.