When removing a user form a Role in Drupal, you get this error in 4.2.8.

Fatal error: Call to undefined function civicrm_api() in civicrm_starterkit/modules/civicrm/drupal/modules/civicrm_group_roles/civicrm_group_roles.module on line 590

This does not happen in 4.3-beta3, but not sure why. The function causing the error appears the same...

/**
 * Helper function to add and remove users from groups, use after user_save to remove roles $roles = $edit['roles'] for user_save
 * @roles list of role to add/remove
 * @user Drupal user object
 * $op either add or remove
 */
function civicrm_group_roles_add_remove_groups($roles, $user, $op) {
  if ($op == 'add') {
    $txt = 'added';
  }
  elseif ($op == 'remove') {
    $txt = 'removed';
  }
  else {
    return;
  }
  $debug_mode = FALSE;

  // make sure user has other roles other than authenticated
  if ($roles) {

    //find the contact record
    $params = array('version' => 3, 'sequential' => 1, 'email' => $user->mail );
    $contact = civicrm_api('contact', 'get', $params);

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kreynen’s picture

adding civicrm_initialize() at the beginning of the function solved the problem

kreynen’s picture

Status: Active » Needs review
kreynen’s picture

Status: Needs review » Closed (won't fix)
kreynen’s picture

Issue summary: View changes

removed ca path