Make WordPress Core

Opened 17 years ago

Closed 17 years ago

Last modified 17 years ago

#3439 closed defect (bug) (wontfix)

Capabilities on mulitple installs sharing usermeta table

Reported by: kafkaesqui's profile Kafkaesqui Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.0.5
Component: Administration Keywords: capabilities roles users usermeta
Focuses: Cc:

Description

One can run multiple instances of WordPress off a single users table (by defining the CUSTOM_USER_TABLE constant), but at present it doesn't quite work for usermeta (with CUSTOM_USER_META_TABLE).

The issue as I see comes down to a line in the WP_User function (WP_User class in capabilities.php):

$this->cap_key = $table_prefix . 'capabilities';

As $table_prefix holds the value of the current weblog's table prefix, this invalidates role lookups in the primary usermeta table, which uses the primary weblog's table prefix for the 'capabilities' meta_key.

I'm fishing to see what might be the best solution. At the moment I'm thinking adding a new constant to the mix:

define('PSEUDO_TABLE_PREFIX', 'wp_');

and testing for it in capabilities.php:

if ( defined('PSEUDO_TABLE_PREFIX') )
	$this->cap_key = PSEUDO_TABLE_PREFIX . 'capabilities';
else
	$this->cap_key = $table_prefix . 'capabilities';

is the way to go, but it feels a bit hacky.

Related tickets:
http://trac.wordpress.org/ticket/2378
http://trac.wordpress.org/ticket/2622

Change History (4)

#1 follow-up: @markjaquith
17 years ago

  • Milestone 2.0.6 deleted
  • Resolution set to wontfix
  • Status changed from new to closed

No, that's intentional. Otherwise, you wouldn't be able to have per-weblog roles and capabilities. So this way, one weblog stores all the roles, caps and users, but the roles and caps can be different for each blog. If you want them to be synced, you should write a script that syncs permissions across the other blogs upon them being changed in any of the blogs.

#2 in reply to: ↑ 1 ; follow-up: @Kafkaesqui
17 years ago

Replying to markjaquith:

No, that's intentional.

It's intentional for WordPress to be broken? Because that is how it appears to regular users, as things stand.

Otherwise, you wouldn't be able to have per-weblog roles and capabilities.

Then one chooses not to define CUSTOM_USER_META_TABLE (and the pseudo prefix constant I suggest above). You see we already provide a way for users to override "per-weblog roles and capabilities," but it does not work as advertised.

If you want them to be synced, you should write a script that syncs permissions across the other blogs upon them being changed in any of the blogs.

I'll be sure to pass that suggestion along to users in the support forums. That is, after they've posted about defining CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE and still being unable to get in with their primary installation's logins.

#3 in reply to: ↑ 2 @markjaquith
17 years ago

  • Milestone set to 2.1

Okay, I see where the connection was missed:

CUSTOM_USER_META_TABLE wasn't intended to offer role/capabilities sharing across blogs, which is what you (or the users in the forums) want to do. We could, however, offer that functionality. Note that this will take away their ability to tweak roles/caps on one blog and not have them affect all other blogs.

See: #3444

#4 @markjaquith
17 years ago

  • Milestone 2.1 deleted

didn't mean to touch the milestone...

Note: See TracTickets for help on using tickets.