1

****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.com 3 occurences of $other_prefixes = array( 'wp5l_', ); fpw-sync-users.php in forum.oursite.com 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.org and when they login, they will have access to forums.oursite.org.

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.com and forum.oursite.com

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

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

  1. I exported all the database tables from forum.oursite.com (except for wp5l_user and wp5l_usermeta) and imported them into the test.oursite.com 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.com, I copied the entire wp-config.php file to forum.oursite.com's root.

  3. I went in to edit forum.oursite.com'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.com and added the below defines and saved it.

    define('COOKIE_DOMAIN', '.test.oursite.com'); //this is where I think the problem might be define('COOKIEPATH', '/'); define('COOKIEHASH', md5('test.oursite.com')); 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.com and saved it.

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

7 I created fpw-sync-users.php in the mu-plugins folder for test.oursite.com 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.com and copied the same code from the test.oursite.com 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.com and logged in, then went to forum.oursite.com 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.com. 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.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
    Possible duplicate of Single sign on between two wordpress website – Drupalizeme Dec 31 '17 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 Dec 31 '17 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 Dec 31 '17 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.org, secure.oursite.org, and forums.oursite.org. All three sites use one, common database, and your shared user tables should be these from secure.oursite.org. 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 Jan 1 '18 at 1:55
  • @FrankP.Walentynowicz The table prefixes for the two test sites we are focusing on for now are: test.oursite.com - wp7g and forum.oursite.com - wp5l . I exported the database tables (except wp5l_user and wp5l_usermeta) from the forum.oursite.com database and imported them into the test.oursite.com database. – fdarn Jan 1 '18 at 2:24
1

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

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

to:

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

Go to test.oursite.com/wp-admin/ and login as an administrator. Go to Users -> Your Profile and click on Update Profile button. Now go to forums.oursite.com/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.

  • Hello @Frank, I finally had a chance to try this. I started over again, doing exactly as you said. As far as I can tell everything is correct including the synchronization plugin. fpw-sync-users.php in test.oursite.com 3 occurences of $other_prefixes = array( 'wp5l_', ); fpw-sync-users.php in forum.oursite.com 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 – fdarn Jan 3 '18 at 3:07
  • If their a way a could share a zip folder of my config files and the sync user files so they can be looked over? I know I must be doing something wrong here and I really want to get this to work. – fdarn Jan 4 '18 at 1:08
  • @fdarn: sorry, I was very busy. I think it would be much easier to do it together via remote session. It should be done in 20-30 minutes tops. If you decide to do it, please give me a call @ 780-641-9455 around 7pm (MST). – Frank P. Walentynowicz Jan 5 '18 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.