Title: WordPress 2.5 Share users table
Last modified: August 19, 2016

---

# WordPress 2.5 Share users table

 *  [denadai2](https://wordpress.org/support/users/denadai2/)
 * (@denadai2)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/)
 * How can i share user between 2 or more blogs in this way?
 * [http://wordpress.org/support/topic/116181?replies=17](http://wordpress.org/support/topic/116181?replies=17)
 * (this was for 2.x.x)
 * thx

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/wordpress-25-share-users-table/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/wordpress-25-share-users-table/page/2/?output_format=md)

 *  [kevinstory](https://wordpress.org/support/users/kevinstory/)
 * (@kevinstory)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724181)
 * I am interested in how to do this as well. Thanks!
 *  [sroyalty](https://wordpress.org/support/users/sroyalty/)
 * (@sroyalty)
 * [18 years, 2 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724306)
 * So far it is partly like the 2.3 mod. Below is how my 2.5 shares. Now, this is
   for the same access across all shared blogs. I have not set it up to give unique
   access per blog.
 * wp-config.php in the 2nd, 3rd, etc (not first install though).
    Before the line
   with define(‘ABSPATH’, dirname(__FILE__).’/’);
 *     ```
       // Let's add the code for sharing a user db table within the wordpress database.
       // Remember, all blogs must be installed to the same database, with unique prefix's.
       // These entries point to the single blog's userbase to share.
       define('CUSTOM_USER_TABLE', 'wp_users');
       // Uncomment this to use the same usermeta globally for roles.
       define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
       ```
   
 * Then I made the following change to wp-includes/wp-capabilities.php
    Find the
   line: `$this->cap_key = $wpdb->prefix . 'capabilities';` Change it too: `$this-
   >cap_key = ‘wp_capabilities’;`
 *  [Khairil Zhafri](https://wordpress.org/support/users/poppacket/)
 * (@poppacket)
 * [18 years, 1 month ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724398)
 * I am getting this error:
 * Fatal error: Cannot access empty property in /home/poppacket/domains/domain2.
   com/public_html/wp-includes/capabilities.php on line 169
 *  [Khairil Zhafri](https://wordpress.org/support/users/poppacket/)
 * (@poppacket)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724478)
 * 1. Upgrade to 2.6.
 * 2. Make sure all WordPress instances on the same database.
 * 3. Say the primary blog have table prefix set to `wp_` and the secondary ones
   with `wp2_` `wp3_` etc. Add the following in _wp-config.php_ of the secondary
   installations:
 *     ```
       define('CUSTOM_USER_TABLE', 'wp_users');
       define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
       ```
   
 * Very neat with v 2.6!
 *  [harringtonjw](https://wordpress.org/support/users/harringtonjw/)
 * (@harringtonjw)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724482)
 * I have added the two lines shown above and get the following error:
 * You do not have sufficient permissions to access this page
 * Is there anything else I need alter in the user table?
 *  [marschelios](https://wordpress.org/support/users/marschelios/)
 * (@marschelios)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724484)
 * Just upgraded to 1.6.1 and decided to add another blog to a subdomain but wanted
   users spread over both blogs. Took a while but figured it out with some help 
   from a guy named ringmaster ([http://trac.wordpress.org/ticket/2378](http://trac.wordpress.org/ticket/2378)).
 * The problem appears to be a difference of opinion between users and WP programmers.
   Most users seem to think that a user should share the capabilities between blogs
   if they share the same database, where the programmers want the flexibility to
   allow users different caps between sites.
 * harringtonjw, in short our problem is even though we have successfully shared
   the databases, with poppackets code, your users caps are not brought over and
   you dont have admin rights.
 * To share user caps, you need to create another define in wp-config, I called 
   mine CUSTOM_CAPABILITES_PREFIX and set it to the prefix of your master db.
 * Now, in wp-includes/capabilities.php scroll down to WP_User and where it is has:
 *     ```
       $this->cap_key = $wpdb->prefix . 'capabilities';
       ```
   
 * Replace it with this:
 *     ```
       if (defined ('CUSTOM_CAPABILITES_PREFIX')) {
         $this->cap_key = CUSTOM_CAPABILITES_PREFIX . 'capabilities';
       }
       else {
         $this->cap_key = $wpdb->prefix . 'capabilities';
       }
       ```
   
 * After this, you should be able to log in to your new site with your master password
   successfully.
 *  [ron_g](https://wordpress.org/support/users/ron_g/)
 * (@ron_g)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724486)
 * The code worked for me perfectly but I am still running into the problem that
   users have to log in at each separate blog. Is there any way around this? Thanks.
 *  [michuk](https://wordpress.org/support/users/michuk/)
 * (@michuk)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724487)
 * I have two blogs, one on WP 2.6.1, one on 2.4.*. I’d like to share the user data
   between those. Unfortunately when I’m applying these tips, it all works on the
   new blog (on 2.6.1) but on the old one I cannot login anymore with my credentials.
   Is this due to same database changes? Where are the caps held in the database?
   Do you know of any fix for that exept upgrading to 2.6.1 on all blogs (can’t 
   do it for multiple reasons now).
 *  [marschelios](https://wordpress.org/support/users/marschelios/)
 * (@marschelios)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724488)
 * ron_g: I ran into this too and couldn’t really figure out a good way around it.
   From what I understand, it’s how sessions are supposed to work between domains,
   even if they are subdomains. I wonder if it could be possible to modify the login
   code to log the user into both domains? Something to look into…
 * michuk: I would upgrade to the same version, I’m sure it’s possible, but there’s
   no telling what other problems you would run into with the differences.
 *  [zodiaco](https://wordpress.org/support/users/zodiaco/)
 * (@zodiaco)
 * [17 years, 9 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724498)
 * I installed 2 worpress with different prefix:
    blog_ (for my blog) & portal_ (
   for the portal)
 * I did all what you guys said here and sees work good but… good not mean perfect.
   When I try to log in to the Portal I couldn’t have access to the Blog admin panel(
   wp-admin). But when I log in to the Blog and check my Portal I could see the 
   link that show the online/offline status said I am logged in and not logged out:
   S. Maybe I need to edit something from the wp-admin directory but I have no idea
   where I am novice in this and I need help so if you know could you tell me :<?
   Send me a e-mail to: [zodiaco@hacrak.co.cc](https://wordpress.org/support/topic/wordpress-25-share-users-table/zodiaco@hacrak.co.cc?output_format=md)
 * Thank you.
 *  [neil-t](https://wordpress.org/support/users/neil-t/)
 * (@neil-t)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724523)
 * Hi All
 * Thank you for all you comments here as they do help me to understand what wp 
   is doing and how to update it.
 * I’ve followed the steps above but still get the ‘You do not have sufficient permissions
   to access this page.’ on site number 2 !
 * I’ve added the following to the wp-config file from poppacket
 * define(‘CUSTOM_USER_TABLE’, ‘wp_users’);
    define(‘CUSTOM_USER_META_TABLE’, ‘wp_usermeta’);
 * As per MarsChelios comments I have also added
 * define(‘CUSTOM_CAPABILITIES_PREFIX’, ‘wp_’);
 * and in capabilities.php I have changed
 * $this->cap_key = $wpdb->prefix . ‘capabilities’;
 * to
 * if (defined (‘CUSTOM_CAPABILITES_PREFIX’)) {
    $this->cap_key = CUSTOM_CAPABILITES_PREFIX.‘
   capabilities’; } else { $this->cap_key = $wpdb->prefix . ‘capabilities’; }
 * but still I get ‘You do not have sufficient permissions to access this page.’
   Can someone please tell me what I’m doing wrong here ?
 * In addition I want to share all the tables from my main site (excluding options)
   on site 2. I know I may have duplicate content issues on the search engines but
   I’m not that bothered about that.
 * Please help if you can, thanks
 *  [peterassmann](https://wordpress.org/support/users/peterassmann/)
 * (@peterassmann)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724524)
 * Actually I have the same problem. Tried with the code of Neil T and I doesnt 
   work still, having the same error. “You do not have sufficient permissions to
   access this page.” hope you’ll be able to help us. 🙁
 *  [taffeljohan](https://wordpress.org/support/users/taffeljohan/)
 * (@taffeljohan)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724525)
 * Neil T and peterassman: There is a typo in the code.
 * `CUSTOM_CAPABILITES_PREFIX` should be `CUSTOM_CAPABILITIES_PREFIX`.
 *  [taffeljohan](https://wordpress.org/support/users/taffeljohan/)
 * (@taffeljohan)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724526)
 * [@neil](https://wordpress.org/support/users/neil/) T
 * I’m sick in bed and amusing myself by answering forum questions today.
 * With regard to your question about using the same tables in a second blog. You
   could just change the table prefix in the init action, while preserving the options.
   Put something like this in a plugin:
 *     ```
       function table_prefix_switch() {
           global $wpdb;
           $options = $wpdb->options; //Save the site 2 options table
           $wpdb->set_prefix('wp_'); //The prefix to site 1
           $wpdb->options = $options; //Put the options table back
       }
   
       add_action('init', 'table_prefix_switch');
       ```
   
 * I haven’t tested this, but have used `$wpdb->set_prefix()` often for various 
   hacks and switching blogs this way works well.
 *  [neil-t](https://wordpress.org/support/users/neil-t/)
 * (@neil-t)
 * [17 years, 7 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/#post-724527)
 * [@taffeljohan](https://wordpress.org/support/users/taffeljohan/)
 * You my friend, are an absolute genius !
 * I put that code in a plugin file, uploaded, activated and hey presto……….My 500
   + articles from my other site appeared.
 * Love it, thanks and get well soon 🙂

Viewing 15 replies - 1 through 15 (of 26 total)

1 [2](https://wordpress.org/support/topic/wordpress-25-share-users-table/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/wordpress-25-share-users-table/page/2/?output_format=md)

The topic ‘WordPress 2.5 Share users table’ is closed to new replies.

## Tags

 * [multiple](https://wordpress.org/support/topic-tag/multiple/)
 * [table](https://wordpress.org/support/topic-tag/table/)

 * 26 replies
 * 16 participants
 * Last reply from: [j-hai](https://wordpress.org/support/users/j-hai/)
 * Last activity: [17 years, 4 months ago](https://wordpress.org/support/topic/wordpress-25-share-users-table/page/2/#post-724563)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
