I am trying to assign a group from currently logged in user(One group in assigned only) to a newly created individual.
function search_civicrm_post($op, $objectName, $objectId, &$objectRef){ {
$getContactId = (int) CRM_Core_Session::singleton()->getLoggedInContactID();
try {
$result = civicrm_api3('GroupContact', 'getsingle', [
'return' => ["group_id"],
'contact_id' => $getContactId,
]);
}
catch (CRM_Exception $e) {
echo "error";
}
$getGroupId = $result['group_id'];
$recentContactId= '';
$query ="INSERT INTO `civicrm_group_contact` (`group_id`, `contact_id`, `status`) VALUES ('.$getGroupId', '$recentContactId','Added')";
But problem is that how will I get the id of recently added individuals;