WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying out the SharDB plugin, but it doesn't seem to be respecting my CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE declarations -- it is querying $shardb_prefix.users instead of my custom table name. Anyone know if this plugin is supposed to support the CUSTOM_USER_TABLE definitions?


share|improve this question
up vote 1 down vote accepted

Ok, looking into this, I found a little bug in the tables function (beginning on line 1088) in the db.php script file that comes with SharDB.

It was this bit of code that was the problem (starting on line 1114 of db.php):

if ( isset( $tables['users'] ) ) {
    if( defined( 'CUSTOM_USER_TABLE' ) ) 
        $pre_tables['users'] = CUSTOM_USER_TABLE;
    if ( defined( 'CUSTOM_USER_META_TABLE' ) ) 
        $pre_tables['usermeta'] = CUSTOM_USER_META_TABLE;

See, it does check before it returns the tables list to see if CUSTOM_USER_TABLE and CUSTOM_USER_META_TABLE are defined, and overwrites the default values if they are. However the check was not running in the first place because of the isset( $tables['users'] ) check on line 114. $tables is an array of table names, 'users' is one of the values in the array, so $tables['users'] is never set.

So change line 114 to:

if ( isset( $pre_tables['users'] ) )

and voila. You're all set

(I'm gonna go find the plugin author now and report the bug!)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.