Author Topic: Create user from contact - not working  (Read 3159 times)

aportet

  • Newbie
  • *
  • Posts: 7
    • View Profile
Create user from contact - not working
« on: May 30, 2009, 05:15:44 am »
Hi to those who have an idea or a solution.

I'm pushing my OpenGoo users to first create contacts before creating users.

However, this is not working and I'm obliged later on, to correct it directly on the MySQL base. The user ID is not implemented in the contact so that there is no link between both.

Using 1.4 and 1.4.1 (same problem)

If someone has "THE" solution, in advance many thanks !!

ignacio

  • Hero Member
  • *****
  • Posts: 1703
    • View Profile
Re: Create user from contact - not working
« Reply #1 on: June 01, 2009, 04:56:50 pm »
Hi,

To correct the problem you have to edit file 'application/controllers/UserController.class.php' and change lines 191 to 196, from:

Code: [Select]
// if contact with same email exists use it as user's contact, without changing it
$contact = Contacts::getByEmail($user->getEmail(), true);
if ($contact instanceof Contact) {
$contact->setUserId($user->getId());
if ($contact->isTrashed()) $contact->untrash();
}

to:

Code: [Select]
$contact_id = array_var($user_data, 'contact_id');
$contact = Contacts::findById($contact_id);
if ($contact instanceof Contact) {
// user created from a contact
$contact->setUserId($user->getId());
$contact->save();
} else {
// if contact with same email exists use it as user's contact, without changing it
$contact = Contacts::getByEmail($user->getEmail(), true);
if ($contact instanceof Contact) {
$contact->setUserId($user->getId());
if ($contact->isTrashed()) $contact->untrash();
$contact->save();
}
}

For version 1.5 this will be corrected along some small improvements like updating the contacts email and company when you change them for the user, and how the username is generated when creating a user from a contact.

Cheers.

aportet

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Create user from contact - not working
« Reply #2 on: June 02, 2009, 04:00:52 am »
As usual ignacio, great job, works perfectly !!

Thanks you "very much", please continue. I will try my best to forward you any kind of bugs and evolution possibility. (is there a page or a wish list  where we can write our proposal ?)

Looking forward seeing the 1.5 !!

alvarotm01

  • Administrator
  • Sr. Member
  • *****
  • Posts: 335
    • View Profile
    • Email
Re: Create user from contact - not working
« Reply #3 on: June 08, 2009, 12:06:33 pm »
Hi,

To propose new features, you can do it in this forum at boards "New Features" or "Ideas"

greetings