[wp-trac] [WordPress Trac] #13635: Bug in capabilities and custom user and usermeta tables
WordPress Trac
wp-trac at lists.automattic.com
Sun May 30 11:08:06 UTC 2010
#13635: Bug in capabilities and custom user and usermeta tables
--------------------------+-------------------------------------------------
Reporter: czepol | Owner: ryan
Type: defect (bug) | Status: new
Priority: high | Milestone: Future Release
Component: Database | Version:
Severity: normal | Keywords:
--------------------------+-------------------------------------------------
I own 2 blogs based on WordPress with one instance for each of them. I use
"wp_" table prefix for the first, "wp_blog_" for the other one. In a wp-
config.php file used by the second blog (that one with "wp_blog_" prefix),
I set two constans:
define( 'CUSTOM_USER_TABLE', 'wp_users' );
define( 'CUSTOM_USER_META_TABLE', 'wp_usermeta' );
Someone forgot about 'wp_capabilities'. If I didn't change capabilities's
table to "wp_capabilities" for blog which has table prefix "wp_blog_" I
can't login on the blog (Error: "You do not have sufficient permissions to
access this page."). It's needed to add some code to wp-
includes/capabilites.php in function "_init_caps( $cap_key = "" )". Now
the _init_caps looks like this:
{{{
function _init_caps( $cap_key = '' ) {
global $wpdb;
if ( empty($cap_key) )
$this->cap_key = $wpdb->prefix . 'capabilities';
else
$this->cap_key = $cap_key;
$this->caps = &$this->{$this->cap_key};
if ( ! is_array( $this->caps ) )
$this->caps = array();
$this->get_role_caps();
}
}}}
I propose to change this function to:
{{{
function _init_caps( $cap_key = '' ) {
global $wpdb;
if ( empty($cap_key) )
$this->cap_key = $wpdb->prefix . 'capabilities';
else
$this->cap_key = $cap_key;
$this->caps = &$this->{$this->cap_key};
if ( defined('CUSTOM_CAPABILITIES_TABLE') )
$this->cap_key = CUSTOM_CAPABILITIES_TABLE;
if ( ! is_array( $this->caps ) )
$this->caps = array();
$this->get_role_caps();
}
}}}
Finally, I must set a constant 'CUSTOM_CAPABILITIES_TABLE' in wp-
config.php.
http://codex.wordpress.org/Editing_wp-
config.php#Custom_User_and_Usermeta_Tables
--
Ticket URL: <http://core.trac.wordpress.org/ticket/13635>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list