Email signup fails when user is already a contact
Hi,
We have several lists in sendgrid and our blog newsletter signup adds users to one. When the user is already a contact (as a result of being on one of the other lists) the newsletter signup fails with the general error template/msg: "Something went wrong while trying to send information."
I've debugged this and it looks like the issue is with the static add_recipient method of the class Sendgrid_NLVX in the file class-snedgrid-nlvx.php. In particular this bit:
if ( ! isset( $recipient_response['persisted_recipients'] ) or ! isset( $recipient_response['persisted_recipients'][0] ) ) {
return false;
}
Since the api call returns unmodified_recipients=[0] when the email already exists as a contact, and persisted_recipients=[] this method is failing here.
In this case I guess we also need to fetch the recipient id from sendgrid for the existing contact/email and then we can proceed to add it to the correct list as per usual.
Thanks