0

I am trying to get a group id of currently logged in user

function search_civicrm_preProcess($formName, &$form) { $getContactId = (int) CRM_Core_Session::singleton()->getLoggedInContactID(); $query = "select 'group_id' from 'civicrm_group_contact' where contact_id ='.$getContactId'"; $dao1 =& CRM_Core_DAO::executeQuery( $query, CRM_Core_DAO::$_nullArray );
}

1 Answer 1

1

I would use api to find groups of logged in user

$result = civicrm_api3('Contact', 'getsingle', [
  'return' => ["group"],
  'id' => 'user_contact_id',
]);

or 

$result = civicrm_api3('GroupContact', 'getsingle', [
  'return' => ["group_id"],
  'contact_id' => 'user_contact_id',
]);

HTH

Pradeep

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.