如何通过一次登录访问多个WordPress站点

时间:2017-12-31 作者:fdarn

****请参见下面的编辑****

Edit added 1/4/2018 我按照指示重新开始。就我所知,一切都是正确的,包括同步插件。fpw同步用户。测试中的php。我们的网站。com 3出现$other\\u前缀=数组(\'wp5l\\u\',);fpw同步用户。论坛中的php。我们的网站。com 3$other\\u前缀的出现次数=数组(\'wp7g\\u\',);对吗?当我尝试登录任何一个站点时,会发生什么情况?它只是刷新登录页面,什么也没有发生。没有错误消息

****结束编辑****

我的组织正在使用WordPress 4.9.1。

我们希望实现的是让成员在secure上创建用户配置文件。我们的网站。org,当他们登录时,他们将有权访问论坛。我们的网站。组织。

我无法找到完成此任务的更新说明。这里有谁能告诉我需要做些什么来完成这项工作,或者从哪里获得最新的说明?

非常感谢。

****其他信息****我多次按照@Frank P.的指示在该链接上进行操作,但它不起作用。我不得不把一切都恢复到原来的样子。请看下面我采取的步骤,如果我做错了什么,请告诉我。

我尝试在其上测试单个登录设置的站点位于子域上:test。我们的网站。com和论坛。我们的网站。com公司

测验我们的网站。com的数据库前缀是wp7gforum。我们的网站。com的数据库前缀为wp5l

我想要测试。我们的网站。com是创建用户的位置。

我从论坛导出了所有数据库表。我们的网站。com(wp5l\\u user和wp5l\\u usermeta除外)并将它们导入测试。我们的网站。com数据库。

我进去编辑wp配置。按照Frank P.的指示,在这个链接上创建php文件Single sign on between two wordpress website他说两个wp配置。php文件必须相同,除了$table\\u prefix处的前缀,该前缀应显示其数据库的原始前缀。因为我想在测试中创建登录名。我们的网站。com,我复制了整个wp配置。php文件到论坛。我们的网站。com的根目录。

我去编辑论坛了。我们的网站。com的wp配置。php文件,并将$table\\u前缀更改为wp5l,然后将其保存。

我去编辑wp配置。php用于测试。我们的网站。com并添加了以下定义和保存。

定义(\'COOKIE_DOMAIN\',\'test.oursite.com\')//这就是我认为问题可能在于定义(\'COOKIEPATH\',\'/\');define(\'COOKIEHASH\',md5(\'test.oursite.com\');定义(\'CUSTOM\\u USER\\u TABLE\',\'wp7g\\u users\');定义(\'CUSTOM\\u USER\\u META\\u TABLE\',\'wp7g\\u usermeta\');

我将这些相同的定义复制并粘贴到wp config。论坛中的php。我们的网站。com并将其保存。

我在wp内容中为这两个测试创建了mu插件文件夹。我们的网站。com和论坛。我们的网站。组织机构

我创建了fpw同步用户。用于测试的mu plugins文件夹中的php。我们的网站。com并复制了Frank P的代码,然后将3个区域更改为“我的前缀”,并将其保存为如下所示。

$other_prefixes = array(
    \'wp7g_\',
);
我创建了fpw同步用户。论坛的mu plugins文件夹中的php。我们的网站。com并从测试中复制了相同的代码。我们的网站。com mu plugins文件夹,因此前缀是wp7g,正如Frank所说的那样。我保存了它

非常感谢。

******wp配置。php用于测试。我们的网站。com公司*****

<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don\'t have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'oursite_test2\');


/** MySQL database username */
define(\'DB_USER\', \'oursite_test2\');


/** MySQL database password */
define(\'DB_PASSWORD\', \'hidden\');


/** MySQL hostname */
define(\'DB_HOST\', \'localhost\');


/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'hidden\');


/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');


/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */

define(\'AUTH_KEY\',hidden\');

define(\'SECURE_AUTH_KEY\',  \'hidden\');

define(\'LOGGED_IN_KEY\',    \'hidden\');

define(\'NONCE_KEY\',        \'hidden\');

define(\'AUTH_SALT\',        \'hidden\');

define(\'SECURE_AUTH_SALT\', \'hidden\');

define(\'LOGGED_IN_SALT\',   \'hidden\');

define(\'NONCE_SALT\',       \'hidden\');


define(\'COOKIE_DOMAIN\',         \'.test.oursite.com\');

define(\'COOKIEPATH\',            \'/\');

define(\'COOKIEHASH\',            md5(\'test.oursite.com\'));


define(\'CUSTOM_USER_TABLE\', \'wp7g_users\');

define(\'CUSTOM_USER_META_TABLE\', \'wp7g_usermeta\');


/**#@-*/


/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = \'wp7g_\';


/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */

define(\'WP_DEBUG\', false);


/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . \'wp-settings.php\');


****wp-config.php for forum.oursite.com*****


<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don\'t have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */


// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define(\'DB_NAME\', \'oursite_test2\');


/** MySQL database username */
define(\'DB_USER\', \'oursite_test2\');


/** MySQL database password */
define(\'DB_PASSWORD\', \'hidden\');


/** MySQL hostname */
define(\'DB_HOST\', \'localhost\');


/** Database Charset to use in creating database tables. */
define(\'DB_CHARSET\', \'hidden\');


/** The Database Collate type. Don\'t change this if in doubt. */
define(\'DB_COLLATE\', \'\');


/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */

define(\'AUTH_KEY\',hidden\');

define(\'SECURE_AUTH_KEY\',  \'hidden\');

define(\'LOGGED_IN_KEY\',    \'hidden\');

define(\'NONCE_KEY\',        \'hidden\');

define(\'AUTH_SALT\',        \'hidden\');

define(\'SECURE_AUTH_SALT\', \'hidden\');

define(\'LOGGED_IN_SALT\',   \'hidden\');

define(\'NONCE_SALT\',       \'hidden\');


define(\'COOKIE_DOMAIN\',         \'.test.oursite.com\');

define(\'COOKIEPATH\',            \'/\');

define(\'COOKIEHASH\',            md5(\'test.oursite.com\'));


define(\'CUSTOM_USER_TABLE\', \'wp7g_users\');

define(\'CUSTOM_USER_META_TABLE\', \'wp7g_usermeta\');


/**#@-*/


/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */

$table_prefix  = \'wp5l_\';


/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */

define(\'WP_DEBUG\', false);


/* That\'s all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */

if ( !defined(\'ABSPATH\') )
    define(\'ABSPATH\', dirname(__FILE__) . \'/\');


/** Sets up WordPress vars and included files. */

require_once(ABSPATH . \'wp-settings.php\');

2 个回复
SO网友:Frank P. Walentynowicz

在两者中wp-config.php 文件,更改以下定义:

define(\'COOKIE_DOMAIN\',         \'.test.oursite.com\');
define(\'COOKIEHASH\',            md5(\'test.oursite.com\'));
收件人:

define(\'COOKIE_DOMAIN\',         \'.oursite.com\');
define(\'COOKIEHASH\',            md5(\'oursite.com\'));
转到test.oursite.com/wp-admin/ 并以管理员身份登录。转到Users -> Your Profile 然后单击Update Profile 按钮现在转到forums.oursite.com/wp-admin/. 您应该在那里登录。如果同步插件在mu-plugins 因为两个站点都是正确的,所以一切都完成了。如果它们不正确,您将收到一条消息,表明您没有访问此页面的权限。在这种情况下,根据我最初的回答,您必须更正同步插件。如果您看到登录表单wp-config.php 文件设置不正确。

SO网友:froger.me

如果你想让网站完全分开,你可以WP Remote Users Sync (免责声明:我是插件的作者)

结束

相关推荐

WordPress MultiSite Theme

我有多个网站。(3个网站)所以我想在其中一个网站上应用不同的主题。但当我激活主题时。所有站点都受到影响。这就是多站点的工作方式吗??有人能澄清一下多站点可以做什么吗?安装多站点(子目录)修改了wp配置。php和。htaccessdefine( \'WP_ALLOW_MULTISITE\', true ); define(\'MULTISITE\', true); define(\'SUBDOMAIN_INSTALL\', false); define(\'DOMAIN_CURREN