Hi all
I have a form where users enter their email and it signs them up to a newsletter. Users can unsubscribe via a link, what I want is to re-subscribe users should they enter their email again in the form.
The Email attribute is unique. So I made a afterFind function like this
public function afterFind(){
if(parent::afterFind()){
$this->oldAttributes = $this->attributes;
if ( $this->oldAttributes['Email'] == $this->Email)
if ($this->MemberStatus == 0)
$this->MemberStatus == 1;
// $this->save(false); tried this but unsuccessful (unsurprisingly)
return true;
}else {
return false;
}
}
Here’s the issue, as Email is unique the model will not save the afterFind changes if the Email exists (So I beleive, ), it won’t even try execute the beforeSave method. It will return the message ‘Email already exists’.
My questions are how can I work around this so it saves, and can I change the output message if the user re-subscribes?
Thanks