Automatic Email Un/Subcriber WeBid 1.2.* ONLY

Add automatic un/subscribe links to your emails

  1. BabyDunk

    BabyDunk Active Member

    Joined:
    Feb 26, 2017
    Messages:
    279
    Likes Received:
    22
    BabyDunk submitted a new resource:

    Automatic Email Un/Subcriber - Add automatic un/subscribe links to your emails

    Read more about this resource...
     
  2. Cash Crusaders NZ

    Cash Crusaders NZ New Member

    Joined:
    Mar 12, 2018
    Messages:
    28
    Likes Received:
    2
    Good Day.
    I am installing this feature but get as far as
    <!-- SET THE KEY ON REGISTRATION -->
    You do not indicated which file must be edited. Sorry, a bit confused. Can you help. Thanks.
     
  3. Cash Crusaders NZ

    Cash Crusaders NZ New Member

    Joined:
    Mar 12, 2018
    Messages:
    28
    Likes Received:
    2
    Hi There,
    I am not sure what make of the last instructions regarding the email template/s I am a bit confused. What must I do about these. Can you stipulate more instructions and detail:

    <!-- use these links in your email templates, making sure to add the correct link/s to the template you're editing -->
    <!-- UNSUBSCRIBE FROM NEWSLETTER -->
    <a href="{SITE_URL}unsubscribe.php?as=nonews&id={USERID}&unsub={USERUNSUB}">{L_unsub_6}</a>
    <!-- UNSUBSCRIBE FROM NOTIFICATIONS -->
    <a href="{SITE_URL}unsubscribe.php?as=nonotify&id={USERID}&unsub={USERUNSUB}">{L_unsub_7}</a>
    <!-- CHANGE NOTIFICATIONS TO ONE PER DAY -->
    <a href="{SITE_URL}unsubscribe.php?as=singlemail&id={USERID}&unsub={USERUNSUB}">{L_unsub_8}</a>
    <!-- CHANGE NOTIFICATIONS TO ONE PER AUCTION CLOSE -->
    <a href="{SITE_URL}unsubscribe.php?as=onemail&id={USERID}&unsub={USERUNSUB}">{L_unsub_9}</a>
    <!-- CHANGE NOTIFICATIONS YOU WON'T GET SETUP COMFIRMATION -->
    <a href="{SITE_URL}unsubscribe.php?as=reccomf&id={USERID}&unsub={USERUNSUB}">{L_unsub_10}</a>

    Thanks for your patience.
     
  4. Cash Crusaders NZ

    Cash Crusaders NZ New Member

    Joined:
    Mar 12, 2018
    Messages:
    28
    Likes Received:
    2
    Hi Again,
    I think I sort of understand the problem around previous response. I used "usermail.inc.php" as a example to create the email templates for each of the 5 change responses. However, I do not know how or where to link the email templates I have created.

    Trying very hard. Not an php fundy. Thanks.
     
  5. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    5,572
    Likes Received:
    546
    At the bottom of the corresponding PHP file is where you link it, in the template set variable area.

    I dont remember the exact code as I have not had a copy of webid for ages now but in the PHP file at the bottom in the template set variable area there should be something like.

    'body' => 'sometemplate.tpl' replace sometemplate.tpl with the name of your template file.
     
    Last edited: Mar 25, 2018
  6. BabyDunk

    BabyDunk Active Member

    Joined:
    Feb 26, 2017
    Messages:
    279
    Likes Received:
    22
    Hello @Cash Crusaders NZ

    I haven't really give complete guide for this plugin in the sense of every single section/file that needs edited . it will take some work on your part. at the time i thought i had gave everything needed but if i get some time to look over everything again i will give complete instruction. maybe when the new template system is added i could write a proper plugin.

    here is a list of the files that might need edited. email_handler.JPG inside these files you will find the template tag/variables for its corresponding email template which can be found /language/THE LANGUAGE/emails/html and the plain text format can be found the next dir down.

    not all templates will need edited as some templates are for admin only which dont need an unsubscribe button but if you're wanting to use this plugin you will need to figure out which templates need the added code


    Say take admin/listusers.php
    PHP:
    if (isset($_GET['resend']) && isset($_GET['id']) && is_numeric($_GET['id'])) {
        
    $query "SELECT id, nick, name, email, hash FROM " $DBPrefix "users WHERE id = :user_id";
        
    $params = array();
        
    $params[] = array(':user_id'$_GET['id'], 'int');
        
    $db->query($query$params);
        if (
    $db->numrows() > 0) {
            
    $USER $db->result();

            
    $emailer = new email_handler();
            
    $emailer->assign_vars(array(
                    
    'SITENAME' => $system->SETTINGS['sitename'],
                    
    'SITEURL' => $system->SETTINGS['siteurl'],
                    
    'ADMINMAIL' => $system->SETTINGS['adminmail'],
                    
    'CONFIRMURL' => $system->SETTINGS['siteurl'] . 'confirm.php?id=' $USER['id'] . '&hash=' md5($MD5_PREFIX $USER['hash']),
                    
    'C_NAME' => $USER['name']
                    ));
            
    $emailer->email_uid $USER['id'];
            
    $emailer->email_sender($USER['email'], 'usermail.inc.php'$system->SETTINGS['sitename'] . ' ' $MSG['098']);
            
    $template->assign_block_vars('alerts', array('TYPE' => 'success''MESSAGE' => $MSG['059']));
        }
    }
    i have added "nletter_key" to the sql select query

    then added the variables needed for the email template (see the add USERUNSUB and USERID)
    PHP:
    if (isset($_GET['resend']) && isset($_GET['id']) && is_numeric($_GET['id'])) {
        
    $query "SELECT id, nick, name, email, hash, nletter_key FROM " $DBPrefix "users WHERE id = :user_id";
        
    $params = array();
        
    $params[] = array(':user_id'$_GET['id'], 'int');
        
    $db->query($query$params);
        if (
    $db->numrows() > 0) {
            
    $USER $db->result();

            
    $emailer = new email_handler();
            
    $emailer->assign_vars(array(
                    
    'SITENAME' => $system->SETTINGS['sitename'],
                    
    'SITEURL' => $system->SETTINGS['siteurl'],
                    
    'USERUNSUB' => $USER['nletter_key'],
                    
    'USERID' => $USER['id'],
                    
    'ADMINMAIL' => $system->SETTINGS['adminmail'],
                    
    'CONFIRMURL' => $system->SETTINGS['siteurl'] . 'confirm.php?id=' $USER['id'] . '&hash=' md5($MD5_PREFIX $USER['hash']),
                    
    'C_NAME' => $USER['name']
                    ));
            
    $emailer->email_uid $USER['id'];
            
    $emailer->email_sender($USER['email'], 'usermail.inc.php'$system->SETTINGS['sitename'] . ' ' $MSG['098']);
            
    $template->assign_block_vars('alerts', array('TYPE' => 'success''MESSAGE' => $MSG['059']));
        }
    }
    then open the /language/EN/emails/html/usermail.inc.php and added the links for the unsubscibe
    HTML:
    <!-- use these links in your email templates, making sure to add the correct link/s to the template you're editing -->
    <!-- UNSUBSCRIBE FROM NEWSLETTER -->
    <a href="{SITE_URL}unsubscribe.php?as=nonews&id={USERID}&unsub={USERUNSUB}">{L_unsub_6}</a>
    <!-- UNSUBSCRIBE FROM NOTIFICATIONS -->
    <a href="{SITE_URL}unsubscribe.php?as=nonotify&id={USERID}&unsub={USERUNSUB}">{L_unsub_7}</a>
    <!-- CHANGE NOTIFICATIONS TO ONE PER DAY -->
    <a href="{SITE_URL}unsubscribe.php?as=singlemail&id={USERID}&unsub={USERUNSUB}">{L_unsub_8}</a>
    <!-- CHANGE NOTIFICATIONS TO ONE PER AUCTION CLOSE -->
    <a href="{SITE_URL}unsubscribe.php?as=onemail&id={USERID}&unsub={USERUNSUB}">{L_unsub_9}</a>
    <!-- CHANGE NOTIFICATIONS YOU WON'T GET SETUP COMFIRMATION -->
    <a href="{SITE_URL}unsubscribe.php?as=reccomf&id={USERID}&unsub={USERUNSUB}">{L_unsub_10}</a>
    
    if my memory serves me right . not all the variable names where set uniformly some of {SITE_URL} are set as {SITEURL} so thats something to be aware of. also sometimes the {SITE_URL} isnt even set for the give template.


    you would be best to search all files for email_handler() call and check to see if the email corresponding to this call needs an unsubscriber. i wish i could be more helpful but i dont have the time at present
     
    Last edited: Mar 26, 2018
  7. Cash Crusaders NZ

    Cash Crusaders NZ New Member

    Joined:
    Mar 12, 2018
    Messages:
    28
    Likes Received:
    2
    Hi
    Sorry to be a bother, but may I ask another question or two.
    1. If I use the User Registration as my example. I sort of understand this one.
    2. When a user registers in register.php the code points to code ../includes/email/user.confirmation.php
    3. user.confirmation.php then points to .../language/html/usermail.inc.php
    4. user.inc.php is specific to email for User Registration.

    I assume the logic for yourS is the same or am I missing it. Oh yes user.confirmation.php uses {SITEURL}
     
  8. BabyDunk

    BabyDunk Active Member

    Joined:
    Feb 26, 2017
    Messages:
    279
    Likes Received:
    22
    Yes @Cash Crusaders NZ that is it. you need to find the php file with the email_handler and set the variables and add the call for
    nletter_key in the sql query therein . then you'll need to find the corresponding email template in the languages/EN/emails/html directory and add the links

    i believe you understand it ;)
     

Share This Page