CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Create Contact, Add to Group, API - ERROR
Pages: [1]

Author Topic: Create Contact, Add to Group, API - ERROR  (Read 2831 times)

asaxe

  • Guest
Create Contact, Add to Group, API - ERROR
October 01, 2007, 12:07:59 pm
Hello:

I'm in the process of developing a custom registration module for my site and using CiviCRM to manage members.  In the custom module I'm making several API calls to create the CiviMember contact and add the member to the group.  The member is successfully created and added to the group, but it seems as if CiviCRM is doing a bunch of other things.  If I print_r the contact object I get the successfully created contact record then about 50 other empty contacts.  Then I get an error (below).  Any thoughts?  Ideas?  Thanks!

Andrew

Error:
Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/website/httpdocs/sites/all/modules/civicrm/packages/HTML/QuickForm.php on line 355

Create Member Code:
if (module_exists('civicrm')) {
   civicrm_initialize(TRUE);
   $civiparams = array(
       'email'         => $edit['mail'],
       'country'       => 'US',
            'first_name'   => '',
       'last_name'      => '',
       'location_type' => 'Work'      
   );
   
   $contact = crm_create_contact($civiparams, 'Individual');

   $groupparams = array('id' => $edit['memtype']);
   $group = crm_get_groups($groupparams);

   $group = $group[0];

   $userparams = array('email' => $edit['mail']);  //doesn't work if I use the $contact object from create
   $contacts = array(crm_get_contact($userparams));
   
   //if ( ! is_a( $contact, 'CRM_Core_Error' ) ) {
        //print_r($contact);
        //} else {
        //echo 'Contact not found.';
        //}
   
   crm_add_group_contacts($group, $contacts, 'Added', 'API');
}

asaxe

  • Guest
Re: Create Contact, Add to Group, API - ERROR
October 01, 2007, 12:09:50 pm
...and the code piece above is running in Drupal hook_user under 'insert'...

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Create Contact, Add to Group, API - ERROR
October 01, 2007, 02:26:32 pm

andrew:

You might want to get on IRC. better place to debug this issue

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Create Contact, Add to Group, API - ERROR

This forum was archived on 2017-11-26.