Advertisement
KardiWeb

2 wordpress user auth

Feb 14th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1.     Install the second WP as normal into the same database as the original with a DIFFERENT table prefix. Activate the theme you want to use.
  2.      
  3.     Now edit these files...
  4.      
  5.     In wp-config:
  6.      
  7.     define('CUSTOM_CAPABILITIES_PREFIX', 'wp_');
  8.     define('CUSTOM_USER_TABLE', 'wp_users');
  9.     define('CUSTOM_USER_META_TABLE', 'wp_usermeta');
  10.      
  11.     In wp-includes/capabilities.php:
  12.     /**
  13.     * Set up capability object properties.
  14.     *
  15.     * Will set the value for the 'cap_key' property to current database table
  16.     * prefix, followed by 'capabilities'. Will then check to see if the
  17.     * property matching the 'cap_key' exists and is an array. If so, it will be
  18.     * used.
  19.     *
  20.     * @since 2.1.0
  21.     *
  22.     * @param string $cap_key Optional capability key
  23.     * @access protected
  24.     */
  25.     function _init_caps( $cap_key = '' ) {
  26.     global $wpdb;
  27.     if ( empty($cap_key) )
  28.     if (defined ('CUSTOM_CAPABILITIES_PREFIX')) {
  29.     $this->cap_key = CUSTOM_CAPABILITIES_PREFIX . 'capabilities';
  30.     } else {   
  31.     $this->cap_key = $wpdb->prefix . 'capabilities';
  32.     }
  33.     else
  34.     $this->cap_key = $cap_key;
  35.     $this->caps = &$this->{$this->cap_key};
  36.     if ( ! is_array( $this->caps ) )
  37.     $this->caps = array();
  38.     $this->get_role_caps();
  39.     }
  40.      
  41.     In the active theme's functions.php:
  42.    function table_prefix_switch() {
  43.    global $wpdb;
  44.    $options = $wpdb->options; //Save the site 2 options table
  45.    $wpdb->set_prefix('wp_'); //The prefix to site 1
  46.    $wpdb->options = $options; //Put the options table back
  47.    }
  48.    add_action('init', 'table_prefix_switch');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement