Overview

Module automatically synchronizes Drupal users to Magento. Upon any action with Drupal user (creation, edition or removal), similar event is performed at Magento.
Also module allows to set up correspondences between user roles at Drupal and user groups at Magento. Each Drupal role is set up in correspondence with Magento user group at admin page.

Module's installation process

During installation, module creates magento_groups table in Drupal database used to store the correspondences between Drupal roles and Magento user groups.

Functions description

magento_users_roles_propagation()

Description: Function calls magento_users_roles_propagation_form form.
This form is used to set up to set up correspondences between user roles at Drupal and user groups at Magento. Drupal makes a query about getting the list of user groups to Magento. It's possible to select one user group from the list for each user role. Upon form (magento_users_roles_propagation_form_submit) submission, all the correspondences are saved to database table (new entries are created or existing are updated).

magento_users_get_group($id)

Arguments: $id is the ID of user role
Return value: $group_id is the ID of user group
Description: Using received user role ID, function figures corresponded user group at Magento.

magento_users_get_user_group($user)

Arguments: $user is the object of type of user
Return value: $customer_group is the ID of user group
Description: Function figures user group for current user.
If user has several roles at Drupal (e.g. authenticated user and test), user group corresponded to test role is taken.

magento_users_user()

Description: Hook, by which synchronization of Drupal users to Magento is performed.
When a new user is created, the user's information (login, password, email address, user group figured out by user role) is gathered and forwarded for new user creation to Magento.
When a user is removed, a search for a Magneto user with a matching email address is performed, and the matching Magneto user is removed.
When a user is edited, the user's updated information (login, password, email address, user group figured out by user role) is gathered. Furthermore, a search for a Magneto user with a matching email address is performed. If the user iss found, the information is forwarded for customer update. Otherwise, it's forwarded for the creation of new user.
Note: If the email address of Drupal user was changed, search of users is performed by old email address.