admin管理员组

文章数量:1398775

****SEE Edits below****

Edit added 1/4/2018 I started over again, following the instructions. As far as I can tell everything is correct including the synchronization plugin. fpw-sync-users.php in test.oursite 3 occurences of $other_prefixes = array( 'wp5l_', ); fpw-sync-users.php in forum.oursite 3 occurrences of $other_prefixes = array( 'wp7g_', ); Is that correct? What happens when I try to log in on either site is it just refreshes the login page and nothing happens. There are no error messages

****END EDIT****

My organization is using WordPress 4.9.1.

What we are hoping to accomplish is having members create a user profile on secure.oursite and when they login, they will have access to forums.oursite.

I have not been able to find updated instructions to complete this task. Can anyone here tell me what I need to do to accomplish this, or where to get the updated instructions?

Thank you

****ADDITIONAL Information***** I followed the instructions from @Frank P. at that link multiple times, and it is not working. I had to put everything back the way it originally was. Please see below for the steps I took and let me know if I did anything wrong.

The sites that I tried to test a Single Logon setup on are on subdomains: test.oursite and forum.oursite

test.oursite's database prefix is wp7g forum.oursite's datebase prefix is wp5l

I want test.oursite to be where the user is created.

  1. I exported all the database tables from forum.oursite (except for wp5l_user and wp5l_usermeta) and imported them into the test.oursite datebase.

  2. I went in to edit the wp-config.php files as instructed by Frank P. at this link Single sign on between two wordpress website He says both wp-config.php files must be identical, except for the prefixes at $table_prefix, which should show the original prefix of their database. Since I want the login to be created in test.oursite, I copied the entire wp-config.php file to forum.oursite's root.

  3. I went in to edit forum.oursite's wp-config.php file and changed the $table_prefix to wp5l then saved it.

  4. I went to edit wp-config.php for test.oursite and added the below defines and saved it.

    define('COOKIE_DOMAIN', '.test.oursite'); //this is where I think the problem might be define('COOKIEPATH', '/'); define('COOKIEHASH', md5('test.oursite')); define('CUSTOM_USER_TABLE', 'wp7g_users'); define('CUSTOM_USER_META_TABLE', 'wp7g_usermeta');

  5. I copied and pasted those same defines to wp-config.php in forum.oursite and saved it.

  6. I created the mu-plugins folder in wp-content for both test.oursite and forum.oursite

7 I created fpw-sync-users.php in the mu-plugins folder for test.oursite and copied Frank P's code, then changed the 3 areas to my prefix and saved it as you see below.

$other_prefixes = array(
    'wp7g_',
);
  1. I created fpw-sync-users.php in the mu-plugins folder for forums.oursite and copied the same code from the test.oursite mu-plugins folder so that the prefix is wp7g as Frank said it should be. I saved it.

That was apparently the last step. I went to test.oursite and logged in, then went to forum.oursite and saw that I was not logged in there. I went to wp-login.php and tried to login with the same credentials from test.oursite. It did not accept those credentials. I tried to log in with the original admin credentials and it would not accept those either. So I tried again to make these custom configurations work several more times, trying different things in case I misunderstood something. Nothing is working. I am hoping someone can look over the steps I have taken and tell me what I am missing.

Thank you.

******wp-config.php for test.oursite*****

<?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 .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 .1/salt/ WordPress 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');

define('COOKIEPATH',            '/');

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


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 
 */

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*****


<?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 .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 .1/salt/ WordPress 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');

define('COOKIEPATH',            '/');

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


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 
 */

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');

****SEE Edits below****

Edit added 1/4/2018 I started over again, following the instructions. As far as I can tell everything is correct including the synchronization plugin. fpw-sync-users.php in test.oursite 3 occurences of $other_prefixes = array( 'wp5l_', ); fpw-sync-users.php in forum.oursite 3 occurrences of $other_prefixes = array( 'wp7g_', ); Is that correct? What happens when I try to log in on either site is it just refreshes the login page and nothing happens. There are no error messages

****END EDIT****

My organization is using WordPress 4.9.1.

What we are hoping to accomplish is having members create a user profile on secure.oursite and when they login, they will have access to forums.oursite.

I have not been able to find updated instructions to complete this task. Can anyone here tell me what I need to do to accomplish this, or where to get the updated instructions?

Thank you

****ADDITIONAL Information***** I followed the instructions from @Frank P. at that link multiple times, and it is not working. I had to put everything back the way it originally was. Please see below for the steps I took and let me know if I did anything wrong.

The sites that I tried to test a Single Logon setup on are on subdomains: test.oursite and forum.oursite

test.oursite's database prefix is wp7g forum.oursite's datebase prefix is wp5l

I want test.oursite to be where the user is created.

  1. I exported all the database tables from forum.oursite (except for wp5l_user and wp5l_usermeta) and imported them into the test.oursite datebase.

  2. I went in to edit the wp-config.php files as instructed by Frank P. at this link Single sign on between two wordpress website He says both wp-config.php files must be identical, except for the prefixes at $table_prefix, which should show the original prefix of their database. Since I want the login to be created in test.oursite, I copied the entire wp-config.php file to forum.oursite's root.

  3. I went in to edit forum.oursite's wp-config.php file and changed the $table_prefix to wp5l then saved it.

  4. I went to edit wp-config.php for test.oursite and added the below defines and saved it.

    define('COOKIE_DOMAIN', '.test.oursite'); //this is where I think the problem might be define('COOKIEPATH', '/'); define('COOKIEHASH', md5('test.oursite')); define('CUSTOM_USER_TABLE', 'wp7g_users'); define('CUSTOM_USER_META_TABLE', 'wp7g_usermeta');

  5. I copied and pasted those same defines to wp-config.php in forum.oursite and saved it.

  6. I created the mu-plugins folder in wp-content for both test.oursite and forum.oursite

7 I created fpw-sync-users.php in the mu-plugins folder for test.oursite and copied Frank P's code, then changed the 3 areas to my prefix and saved it as you see below.

$other_prefixes = array(
    'wp7g_',
);
  1. I created fpw-sync-users.php in the mu-plugins folder for forums.oursite and copied the same code from the test.oursite mu-plugins folder so that the prefix is wp7g as Frank said it should be. I saved it.

That was apparently the last step. I went to test.oursite and logged in, then went to forum.oursite and saw that I was not logged in there. I went to wp-login.php and tried to login with the same credentials from test.oursite. It did not accept those credentials. I tried to log in with the original admin credentials and it would not accept those either. So I tried again to make these custom configurations work several more times, trying different things in case I misunderstood something. Nothing is working. I am hoping someone can look over the steps I have taken and tell me what I am missing.

Thank you.

******wp-config.php for test.oursite*****

<?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/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/secret-key/1.1/salt/ WordPress 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');

define('COOKIEPATH',            '/');

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


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/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*****


<?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/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/secret-key/1.1/salt/ WordPress 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');

define('COOKIEPATH',            '/');

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


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/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');
Share Improve this question edited Jan 4, 2018 at 23:55 fdarn asked Dec 31, 2017 at 6:44 fdarnfdarn 1131 silver badge7 bronze badges 7
  • 2 Possible duplicate of Single sign on between two wordpress website – Drupalizeme Commented Dec 31, 2017 at 8:11
  • @fdarn: I saw your comment for my answer, mentioned by @Drupalizeme. If you still have problems implementing single login, edit your question here, and add the content of your wp-config.php for all three sites. Without seeing the code, I will not be able to help you. – Frank P. Walentynowicz Commented Dec 31, 2017 at 22:44
  • hello @Frank. I was typing my edit to this question when you posted this. I am just testing this on two test sites for now. If it works, I will then move to do it with our main sites. I will post my config code as you asked in a minute. Thank you for checking in. – fdarn Commented Dec 31, 2017 at 23:18
  • @fdarn: it is very hard to decipher your edited question because you don't format pieces of code properly. Just confirm the following - your sites are oursite, secure.oursite, and forums.oursite. All three sites use one, common database, and your shared user tables should be these from secure.oursite. Give me table prefixes of all three sites. Based on that I'll tell you how to edit wp-config.php files for all sites. – Frank P. Walentynowicz Commented Jan 1, 2018 at 1:55
  • @FrankP.Walentynowicz The table prefixes for the two test sites we are focusing on for now are: test.oursite - wp7g and forum.oursite - wp5l . I exported the database tables (except wp5l_user and wp5l_usermeta) from the forum.oursite database and imported them into the test.oursite database. – fdarn Commented Jan 1, 2018 at 2:24
 |  Show 2 more comments

2 Answers 2

Reset to default 1

In both wp-config.php files, change the following defines:

define('COOKIE_DOMAIN',         '.test.oursite');
define('COOKIEHASH',            md5('test.oursite'));

to:

define('COOKIE_DOMAIN',         '.oursite');
define('COOKIEHASH',            md5('oursite'));

Go to test.oursite/wp-admin/ and login as an administrator. Go to Users -> Your Profile and click on Update Profile button. Now go to forums.oursite/wp-admin/. You should be logged in there. If synchronization plugins in mu-plugins for both sites are correct, all is done. If they are incorrect, you'll get a message, that you don't have privileges to access this page. In that case, you'll have to correct synchronization plugins, according to my original answer. If you see login form, your wp-config.php files are not set correctly.

If you want to keep the websites completely separated, you can with WP Remote Users Sync (disclaimer: I am the author of the plugin)

本文标签: multisiteHow Access Multiple Wordpress sites with a single login