Synchronizing users

Created on 27 February 2014, about 11 years ago
Updated 15 May 2025, 2 days ago

Hi,
I successfully use this module for it's initial purpose, but I really need to keep my users synchronized on both master and slave environnements, even if the user hasn't logged in the slave site yet.

<!--break-->

For this, I built a small module consisting in :

function mymodule_synchronize_user_update(&$edit, $account, $category) {
  if (variable_get('bakery_is_master', 0) && $account->is_new) {
    $slaves = variable_get('bakery_slaves', array());
    foreach ($slaves as $slave) {
      $options = array(
        'headers' => array('Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8'),
        'method' => 'POST',
        'data' => 'name=' . $account->name,
        'timeout' => 120,
      );
      $result = drupal_http_request($slave . 'synchronize/user', $options);
    }
  }
}

function mymodule_synchronize_menu() {
  $items['synchronize/user'] = array(
    'page callback' => '_mymodule_synchronize_pull_from_master',
    'access callback' => true,
  );
  return $items;
}

function _mymodule_synchronize_pull_from_master() {
  $name = $_POST['name'];
  watchdog('mymodule_synchronize', '<pre>' . var_export($_POST, true) .'</pre>');
  if (!empty($name)) {
    bakery_request_account($name);
  }
}

The user is created but if I log in the master site and change the user password, the change isn't replicated in the slave site. Does the way I created the user is linked with this problem ?

💬 Support request
Status

Closed: duplicate

Component

Code

Created by

🇫🇷France nishruu

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024