My site configuration is J1.5.5, CB12RC2 and VM1.1.2, PHPBB3.0.2., rokbridge RC5beta2
I am using cb_login module instead of Joomla login and CB is primary method of registeration on my site.
However since I want customers on my site to be able to browse store and place items in cart without first asking them to register I end up with accounts created in joomla and not in CB, if such new users decide to proceed with checkout.
As we know Virtuemart currently does not integrate with CB (or vice versa ) I was ending up having users created in jos_users without them getting synched with jos_comprofiler.
Here is how I went about tackling this problem.
I created a trigger on my jos_users table as below:
**********************************************************************
DELIMITER $$
DROP TRIGGER /*!50032 IF EXISTS */ `yourdb`.`sync_cb`$$
create trigger `yourdb`.`sync_cb` BEFORE UPDATE on `yourdb`.`jos_users`
for each row BEGIN
DECLARE MY_PHONE VARCHAR(64) ;
DECLARE MY_ADD VARCHAR(64) ;
DECLARE MY_CITY VARCHAR(64) ;
DECLARE MY_STATE_2_CODE VARCHAR(64) ;
DECLARE MY_STATE VARCHAR(64) ;
DECLARE MY_COUNTRY_3_CODE VARCHAR(64) ;
DECLARE MY_COUNTRY_ID INT(11) ;
DECLARE MY_COUNTRY VARCHAR(64) ;
DECLARE MY_ZIP VARCHAR(64) ;
IF OLD.activation <> NEW.activation Then
IF not exists (select * from jos_comprofiler where jos_comprofiler.id = NEW.id) Then
SELECT phone_1, concat(address_1, ', ', address_2), city, state, country, zip INTO MY_PHONE, MY_ADD, MY_CITY, MY_STATE_2_CODE, MY_COUNTRY_3_CODE, MY_ZIP
FROM jos_vm_user_info
WHERE user_id = NEW.id
AND address_type = 'BT';
SELECT country_id, country_name INTO MY_COUNTRY_ID, MY_COUNTRY
FROM jos_vm_country
WHERE country_3_code = MY_COUNTRY_3_CODE;
SELECT state_name INTO MY_STATE
FROM jos_vm_state
WHERE state_2_code = MY_STATE_2_CODE
AND country_id = MY_COUNTRY_ID;
INSERT INTO jos_comprofiler (id, user_id, avatarapproved, approved, confirmed, rc_phone,rc_address, rc_city, rc_state, rc_country, rc_zipcode) VALUES (NEW.id, NEW.id, 1, 1, 1, MY_PHONE, MY_ADD, MY_CITY, MY_STATE, MY_COUNTRY, MY_ZIP);
END IF;
END IF;
END;
$$
DELIMITER ;
**********************************************************************
The assumption is that when the user activates the account the jos_users.activation field becomes blank and that is the opportunity to insert record in jos_comprofiler. Please note that I also have some Address related fields in my CB and hence I am just copying those values from the VM tables as user has already provided that information. Please modify the fields assignments and names as per your settings.
The next thing I am looking to do is to create a similar trigger on jos_comprofiler so I may sync/populate the info in VM tables whenever a new user creates or updates their account from CB.
M