Author Topic: unsubscribe on subscribe  (Read 2070 times)

gwill23

  • Posts: 50
    • View Profile
    • http://www.residualenterprises.com
unsubscribe on subscribe
« on: August 31, 2004, 07:33:30 am »
I have 3 lists.  I want people to be able to be signed up for list 1 and list 2 or 3 if they want.  however, if they sign up for list 2 I want them removed from list 3.

Can this happen with listmail?

BGSWebDesign

  • Posts: 625
    • View Profile
    • http://www.bgswebdesign.com
unsubscribe on subscribe
« Reply #1 on: September 01, 2004, 06:12:50 am »
Hi Gunther,

Most likely you'll have to write a Perl script interface that
uses that new LMP interface to add to one list, and subtract
from another.

If you do, please post the sample code here, good luck : )
Thanks,
-Brett
http://www.bgswebdesign.com/Contact-Us.php

*** I do custom List Mail Pro installations ***
Contact me through my website (above)

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
unsubscribe on subscribe
« Reply #2 on: September 13, 2004, 12:25:25 pm »
This is possible with a custom script already implemented into ListMail.  The file /xtra/signup-xtra.php will run after every signup by email or form and after manual additions when copied to the main ListMail folder.

In this file, have the following code replacing the example list numbers (1 and 2) with your own.

Code: [Select]
<?php

if($list=='1'){
 
mysql_query("delete from lm_users where email like '$email' and list = '2'");
}
?>
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

gwill23

  • Posts: 50
    • View Profile
    • http://www.residualenterprises.com
unsubscribe on subscribe
« Reply #3 on: October 11, 2004, 06:48:47 pm »
It may be a bit sloppy.  Clean it up if you wish.  However, in an effort to move people from my free list to a paid list.  

THE ONLY 2 LISTS ON THE SERVER NEVER HAVING THE SITUATION WHERE A SINGLE USER WILL BE SUBSCRIBED TO BOTH LISTS.

I came up with the following code based on the LMinsert.pl at http://listmailpro.com/forum/index.php?topic=171.0

If you want to remove this post DW I won't get my feeling hurt.  I just thought it was pretty good for a new user.  We could probably make it better by adding and and list='1' at the end of the WHERE statement below to make sure it only affects a single person.  Then it doesn't matter if you have a single user signed up for multiple lists.

This is all done in Perl and I have never done anything like this before today so....It works for me but if you think it is garbage tell me what and I'll change it.

Quote
#!/usr/bin/perl
#
#   v1.77 lm_users MySQL Table Format
#
#   id  mediumint(9)   - auto incrementing id
#   uid  varchar(7)      - unique user id, must be generated
#   list  smallint(5)   - list user belongs to
#   fname  tinytext      - first name
#   lname  tinytext      - last name
#   email  tinytext      - email address
#   user1-user10 text   - custom fields 1 thru 10
#   cseq  smallint(6)   - user's current seq # (next followup)
#   cdel  smallint(6)   - days to delay to next followup (0 is next dailymail)
#   cnf  char(1)      - 0=unconfirmed 1=confirmed 2=removed 3=bounced
#   dateadd  date      - YYYY-MM-DD date
#   ipaddr  varchar(15)   - ip address
#   refurl  varchar(75)   - referring URL
#   htmail  char(1)      - 1=HTML+Text 2=Just Text
#   bounces  tinytext   - dont mess with this one :/
#
#

# ListMail Change User Function
#
# This function simply finds the user in Listmail using the email address and updates their information.
#
#********************WARNING!!!!!!!!!!!!!!
# THIS FUNCTION SHOULD NEVER BE USED IF YOU HAVE A SINGLE EMAIL ADDRESS SUBSCRIBED TO MULTIPLE LISTS!!
# IN MY CASE LIST 1 IS A FREE LIST AND LIST 2 IS A PAID LIST.  WHEN THEY UPGRADE THEY NO LONGER NEED THE EMAILS FROM THE FREE LIST.
# All parameters are required: list, email, cseg, cdel
#
# example usage:
# require './LMChange.pl';
#
# LMChange($list,$email,'1','0');


# begin function

use DBI;

sub LMChange {
   if(!$_[0]){
      print 'You must enter a list number';
      return 0;
   }
        if(!$_[1]){
                print 'You must enter an email address';
                return 0;
        }

   $list = $_[0];   $em = $_[1];   $sq = $_[2];    $de = $_[3];  

   # default seq
   if(!$sq){ $sq = '1'; }
   # default delay
   if(!$de){ $de = '0'; }
   

   # You -must- set the MySQL connection information below:

   $sqlhost = 'localhost';
   $sqldb = 'database';
   $utable = 'teble to edit';
   $sqluser = 'db user name';
   $sqlpass = 'db password';


   # End config

   # Begin script

   # Connect to MySQL
   $dbh = '';
   $dbh = DBI->connect("DBI:mysql:$sqldb:$sqlhost",$sqluser,$sqlpass);


   
   $dbh->do("UPDATE lm_users SET list='2',cseq='$sq',cdel='$de' WHERE email='$em'");
   


   return 1;
}
return 1;

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
unsubscribe on subscribe
« Reply #4 on: October 12, 2004, 07:32:30 am »
I have no problems with this.  I hope it works for you. :)
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting