我正在尝试使用后保存逻辑挂钩来清除在测试期间输入的伪造电子邮件地址等。但是,电子邮件地址不会更新。以下是我正在使用的代码。我目前在6.5企业。有没有人知道我可能做错了什么?或者,如何通过后保存逻辑挂钩正确更新/删除电子邮件地址?
谢谢!
$sea = new SugarEmailAddress;
$sea = $bean->emailAddress;
foreach ($bean->emailAddress->addresses as $k=>$emailaddress ) {
if( $ema = $emailaddress['email_address'] ) {
if(
stripos($ema,'@none.com') !== FALSE ||
stripos($ema,'@test.com') !== FALSE ||
stripos($ema,'@nunya.com') !== FALSE ||
stripos($ema,'@testing.com') !== FALSE
) {
$sea->addresses[$k]['emailaddress'] = '' ;
//sugar_die(print_r($sea->addresses));
$sea->save($bean->id,$bean->module_dir);
}
}
}
答案 0 :(得分:0)
要在逻辑挂钩或自定义导入中更新用户的电子邮件地址,您可以使用以下逻辑:
if($bean->email1) {
$sea = new SugarEmailAddress();
// Add a primary email address
$sea->addAddress($bean->email1, true);
// Associate the email address with the given module and record
$sea->save($user_id, "Users");
}