据我所知,使用WordPress默认技巧不可能使用单独的数据库单独安装WordPress,除非您使用“通过API登录”等其他技巧。
所以在你的情况下,我认为有两种方法可以做到这一点。
您可以使用WordPress多站点安装并在子目录中创建第二个或子博客。您可以对用户进行一次身份验证,然后将其重定向到您想要的位置。
确保所有子站点安装在具有不同数据库表前缀的同一数据库中。然后在中定义自定义用户表wp-config.php.
第二种方法-
// Once the sub site has been installed, add these two lines to the sub site\'s wp-config.php file, just before this line:
/* That\'s all, stop editing! Happy blogging. */
//Add these two lines:
define(\'CUSTOM_USER_TABLE\', \'wp_users\');
define(\'CUSTOM_USERMETA_TABLE\', \'wp_usermeta\');
// Make sure you replace “wp_” by the first website table prefix.
如果你
get don’t have sufficient permissions error on profile page 如下所示-
You do not have sufficient permissions to access this page.
然后在您的子站点WordPress安装中,
wp-config.php, 在下面
define(‘CUSTOM_USERMETA_TABLE’, ‘wp_usermeta’); 添加-
define(\'CUSTOM_CAPABILITIES_PREFIX\', \'wp_\');
那么你必须在
wp-includes/capabilities.php$this->cap_key = $wpdb->prefix . \'capabilities\';
并将其替换为-
if (defined (\'CUSTOM_CAPABILITIES_PREFIX\')) {
$this->cap_key = CUSTOM_CAPABILITIES_PREFIX . \'capabilities\';
} else {
$this->cap_key = $wpdb->prefix . \'capabilities\';
}
如果您想保持登录所有站点,则需要将所有WordPress站点设置为使用相同的cookie。目前,每个网站都有自己的cookie参数,因此您的两个网站必须使用相同的cookie参数。所以,仍然在
wp-config.php 更改子站点的
COOKIE_DOMAIN 使用父站点的url:
define(\'COOKIE_DOMAIN\', \'.domain.com\'); //replace with your domain name (the parent site)
define(\'COOKIEPATH\', \'/\');
希望这有帮助。