-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL errors multisite #62
Comments
I've just run into this issue which is reproducible on vanilla WordPress Multisite. It happens when the Groups plugin is activated on a single site in WordPress Multisite (and Multi-Network) and a user who is not a super admin (i.e. subject to Groups capabilities) - and has multiple sites to which they have access - visits the WordPress back-end of the site where Groups is activated. The In cases where only one site has Groups activated, the following MU Plugin should prevent the errors, though it is somewhat flawed because it checks the // Filter the table prefix early.
add_filter( 'groups_get_table_prefix', 'my_groups_table_prefix', 10 );
/**
* Filter the "Groups" database table prefix.
*
* @param str $prefix The current WordPress table prefix.
* @return str $this->db_prefix The main site's table prefix.
*/
function my_groups_table_prefix( $prefix ) {
global $wpdb;
// Return early if there has not been a Multisite switch.
if ( ! ( is_multisite() && ms_is_switched() ) ) {
return $prefix;
}
// Return early if Groups is installed on the site.
$groups_options = get_option( Groups_Options::option_key, 'not-installed' );
if ( 'not-installed' !== $groups_options ) {
return $prefix;
}
// Overwrite with the original site prefix.
if ( ! empty( $GLOBALS['_wp_switched_stack'] ) ) {
$original_site_id = reset( $GLOBALS['_wp_switched_stack'] );
return $wpdb->get_blog_prefix( $original_site_id );
}
return $prefix;
} A better option would be to check if Groups is installed on the switched-to site before calling |
FYI I've made a little MU Plugin that solves this: https://gist.github.com/christianwach/334816adcb29565dbfe35fd8d5c6d5b5 The code should really be ported to the Groups plugin itself, but installing this will fix the problem in the short term. |
WordPress database error Table
DATABASE.PREFIX_groups_capability
doesn't exist for querymade by:
referer: SITE/wp-admin/index.php
The text was updated successfully, but these errors were encountered: