Automatic Email Un/Subcriber WeBid 1.2.* ONLY

Add automatic un/subscribe links to your emails

  1. BabyDunk
    WeBid Version:
    • 1.2.*
    Automatic Email Un/Subscriber lets your users unsubscribe or even subscribe to the email received from your WeBid by using the links you provide in your email. As it is a standard now to have an unsubscribe button on every email. This mod will take the work out of it for the admin.

    <!-- copy files -->
    copy unsubscribe.php to the web root

    copy unsubscribe.tpl to you theme root
    (unsubscribe.tpl is coded for bootstrap you will need to change the css and class to suit your needs if you don't use bootstrap)

    <!-- ADD nletter_key COLUMN TO THE USERS TABLE -->
    Code:
    ALTER TABLE webid_users
    ADD nletter_key varchar(50);
    <!-- SET THE KEY ON REGISTRATION -->

    <!-- add this -->
    PHP:
    // Get Real Unique ID
    function uniqidReal($lenght 32) {
      
    // uniqid gives 32 chars, but you could adjust it to your needs.
      
    if (function_exists("random_bytes")) {
      
    $bytes random_bytes(ceil($lenght 2));
      } elseif (
    function_exists("openssl_random_pseudo_bytes")) {
      
    $bytes openssl_random_pseudo_bytes(ceil($lenght 2));
      } else {
      throw new 
    Exception("no cryptographically secure random function available");
      }
      return 
    substr(bin2hex($bytes), 0$lenght);
    }
    <!-- Below this -->
    PHP:
    function get_hash()
    {
      
    $string '0123456789abcdefghijklmnopqrstuvyxz';
      
    $hash '';
      for (
    $i 0$i 5$i++) {
      
    $rand rand(0, (34 $i));
      
    $hash .= $string[$rand];
      
    $string str_replace($string[$rand], ''$string);
      }
      return 
    $hash;
    }
    <!-- INSERT KEY INTO DATABASE -->

    <!-- Replace this -->
    PHP:
      $query "INSERT INTO " $DBPrefix "users
      (nick, password, hash, name, address, city, prov, country, zip, phone, nletter, email, birthdate,
      suspended, language, groups, balance, timezone)
      VALUES
      (:nick, :password, :hash, :name, :address, :city, :prov, :country, :zip, :phone, :nletter, :email, :birthdate,
      :suspended, :language, :groups, :balance, :timezone)"
    ;
    <!-- With this -->
    PHP:
      $query "INSERT INTO " $DBPrefix "users
      (nick, password, hash, name, address, city, prov, country, zip, phone, nletter, gender, email, birthdate,
      suspended, language, groups, balance, timezone, nletter_key)
      VALUES
      (:nick, :password, :hash, :name, :address, :city, :prov, :country, :zip, :phone, :nletter, :gender, :email, :birthdate,
      :suspended, :language, :groups, :balance, :timezone, :nletter_key)"
    ;

    <!-- Find this -->
    PHP:
    array(':timezone'$_POST['TPL_timezone'], 'str'),
    <!-- Replace with this -->
    PHP:
    array(':timezone'$_POST['TPL_timezone'], 'str'),
    array(
    ':nletter_key'uniqidReal(), 'str')
    <!-- ADD TO MESSAGE.INC.PHP -->
    PHP:
    $MSG['unsub'] = 'Unsubscribe';
    $MSG['unsub_0'] = 'Are you sure you\'re on the mailing list? Because we can\'t seem to find you.';
    $MSG['unsub_1'] = 'You have been successfully removed for the Newsletter mailing list.  <br/>If you would like to re-enable this feature, you can find the settings in your <a href="edit_data.php">User Panel</a>.';
    $MSG['unsub_2'] = 'You have been successfully removed for the notifications list. <br/>If you would like to re-enable this feature, you can find the settings in your <a href="selleremails.php">User Panel</a>.';
    $MSG['unsub_3'] = 'You have successfully changed mail notifications to one cumulative e-mail once a day. <br/>If you would like to disable this feature or change to another, you can find the settings in your <a href="selleremails.php">User Panel</a>.';
    $MSG['unsub_4'] = 'You have successfully changed mail notifications to one e-mail for each closing auction. <br/>If you would like to disable this feature or change to another, you can find the settings in your <a href="selleremails.php">User Panel</a>.';
    $MSG['unsub_5'] = 'You have successfully changed the mail notifications, You will not receive auction setup confirmation e-mails. <br/>If you would like to re-enable this feature, you can find the settings in your <a href="selleremails.php">User Panel</a>.';
    $MSG['unsub_6'] = 'Unsubscribe From The Newsletter.';
    $MSG['unsub_7'] = 'Unsubscribe From Notifications Emails.';
    $MSG['unsub_8'] = 'One Notification Per Day.';
    $MSG['unsub_9'] = 'Notification When Each Auction Ends.';
    $MSG['unsub_10'] = 'No More Confirmation Emails.';
    $MSG['unsub_11'] = 'You don\'t have Authority to make these changes!';


    <!-- use these links in your email templates, making sure to add the correct link/s to the template you're editing -->
    HTML:
    <!-- 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 CLOSED AUCTION -->
    <a href="{SITE_URL}unsubscribe.php?as=onemail&id={USERID}&unsub={USERUNSUB}">{L_unsub_9}</a>
    
    <!-- CHANGE COMFIRMATION NOTIFICATION - YOU WON'T GET SETUP COMFIRMATION -->
    <a href="{SITE_URL}unsubscribe.php?as=reccomf&id={USERID}&unsub={USERUNSUB}">{L_unsub_10}</a>