Hi
How to get Account Primary Email ID
Thanks
Hi
How to get Account Primary Email ID
Thanks
Let's say you're in a logic hook, to get the ID of the primary email address you could use sql:
$account_id = $account->id;
sql = "select email_address_id from email_addr_bean_rel where bean_id = '".$account_id."' and bean_module = 'Accounts' and primary_address = 1 and deleted !=1";
$result = $GLOBALS['db']->query($sql);
while($row = $GLOBALS['db']->fetchByAssoc($result) )
{
$email_address_id = $row['email_address_id'];
}
If you just want the email address and not the ID, you can use:
$primary_email = $account->emailAddress->getPrimaryAddress($account);