[wp-hackers] Why do some user meta entries use the table prefix in the, meta key?

John Blackbourn johnbillion+wp at gmail.com
Mon May 13 12:13:37 UTC 2013


On 13 May 2013 13:06, David Anderson <david at wordshell.net> wrote:
>
> On 13/05/13 13:00, John Blackbourn wrote:
>>
>> The database prefix with the blog ID appended acts as a UUID within
>> the given database. This allows you to share your users and usermeta
>> tables between WordPress installs in the same database, because each
>> has a different database prefix.
>>
>> Example: I have two Multisite installs which share a users and
>> usermeta table. The resulting usermeta keys would be, for example,
>> "foo_{n}_" for one site and "bar_{n}_" for the other. If the database
>> prefix wasn't prepended there would be key collisions.
>>
> Thanks... what I didn't understand was, how/when does that sharing of the
> tables actually happen? For it to happen, one WordPress install would have
> to access tables that are not prefixed with its own $table_prefix, but
> prefixed with something else. I didn't know that WordPress had code to
> access a different set of tables than the one specified in $table_prefix. Or
> is it something that's not coded in WordPress, but someone could use some
> hooks to achieve if they wanted to?

Yeah it's a relatively little-known feature. You can manually specify
the name of the users and usermeta tables and WordPress will use those
instead. See: http://codex.wordpress.org/Editing_wp-config.php#Custom_User_and_Usermeta_Tables


More information about the wp-hackers mailing list