ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Notified when someone unsubscribes from mailing list

May 03, 2013 4:37pm

Subscribe [2]
  • #1 / May 03, 2013 4:37pm

    APGWest

    295 posts

    Is there a way for me to be notified when someone unsubscribes from my mailing list?

  • #2 / May 06, 2013 10:51am

    APGWest

    295 posts

    Anyone?

  • #3 / May 06, 2013 12:24pm

    Bhashkar Yadav

    727 posts

    Hi Don,

    There isn’t any feature for notification on mailing list un-subscription.

    Also, there isn’t any hook associated with un-subscription process.

    So if you would like to have this feature you need to put hack/code for sending email in file “/expressionengine/modules/mailinglist/mob.mailinglist.php” within the function unsubscribe() so that you can get notified when someone unsubscribes from my mailing list.

  • #4 / May 06, 2013 12:58pm

    APGWest

    295 posts

    Thanks Bhashkar.  I was afraid of that.  I’m not comfortable enough to come up with such a hack from scratch.  Know of anyone that has tried this that I could use as a jumping off point?  All I’m looking for is an email to a designated address that tells me the email address that unsubscribed.  Nothing fancy at all.

  • #5 / May 06, 2013 1:39pm

    Bhashkar Yadav

    727 posts

    Don,

    Which version of ExpressionEngine you are using.

    If you would like I can share some code which you can put into the specified file within my previous message.

  • #6 / May 06, 2013 2:00pm

    APGWest

    295 posts

    That would be incredibly kind of you!!  I’m running v2.5.2 at the moment.

  • #7 / May 06, 2013 10:21pm

    Bhashkar Yadav

    727 posts

    Hi Don,

    Put the below code after line number 505 in the file “system/expressionengine/modules/mailinglist/mob.mailinglist.php”

    OR after the line of code:

    $this->EE->db->delete('mailing_list', array('authcode' => $id));

    put these code:

    $query = $this->EE->db->select('email')->get_where('mailing_list', array('authcode' => $id));
    
    if ($query->num_rows() > 0)
    {
     $unsub_email = $query->row('email');
     $message = "Email un-subscribed from your maillist: ".$unsub_email;
    
     $to_email = "youemailaddress";
     $email_subject = "Unsubscribed from mailing list";
    
     $this->EE->load->library('email');
     $this->EE->load->helper('text');
    
     $this->EE->email->EE_initialize();
     $this->EE->email->wordwrap = true;
     $this->EE->email->mailtype = 'html';
     $this->EE->email->from($this->EE->config->item('webmaster_email'), $this->EE->config->item('webmaster_name'));
     $this->EE->email->to($to_email);
     $this->EE->email->subject($email_subject);
     $this->EE->email->message(entities_to_ascii($message));
     $this->EE->email->send();
    }

    See in the code, you need to update value of $to_email with your email.

    Please share if you are facing any problem with this code.

     

    Thanks,

  • #8 / May 07, 2013 11:40am

    APGWest

    295 posts

    Awesome!  Thank you so much Bhashkar!!

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases