Get answers quicker by searching

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

PHP code to move subsribers from one list to another
  • Vote Up0Vote Down robvarobva
    Posts: 1Sendy user

    Hi all,

    I'm no PHP programmer but usually manage pretty well by copying and pasting snippets of code. Because I'm unwilling to use Zapier to move subscribers from one list to another (as ultimately that becomes quite expensive), I have written a bit of code that I run daily through a cron job. It works flawlessly so far, so I figured I might as well share the code. (If you're a PHP programmer and can make the code more elegant, that would be great though.)

    In phpMyAdmin you can look up the numbers of your lists. They're in your Sendy database, in table lists. In there I want to move subscribers from my list 3 to my list 5. You have to look up your own numbers. I want to do that once my subscribers have received my last autoresponder. That's visible in table ares_emails. My last autoresponder message is 12. Again, you have to look up your own number.

    What I want to do, is move my subscribers to list 5, as long as they're still in list 3 and have received autoresponder message number 12.

    This is the code I use:

    <?php  
    
    $link = mysqli_connect("localhost", "user", "password", "sendy-database");  
    
    if($link === false){  
      exit;  
    } 
    
    $sql = "UPDATE subscribers SET list = 5 WHERE list=3 AND last_ares=12";  
    
    if(mysqli_query($link, $sql)){  
      exit;  
    } 
    
    mysqli_close($link);  
    
    ?>
    

    This code is in file movefrom3to5.php in my sendy directory. So the cron job I use is:

    59 23 * * * php /serverpath/domainname.com/public_html/sendy/movefrom3to5.php > /dev/null 2>&1

    Hope that helps!

    Regards,

    Rob

  • 1 Comment
  • Vote Up0Vote Down aw101aw101
    Posts: 2Sendy user

    Beautifully simple, I can see me using that. Thanks for sharing. I'd love to see this added as an optional last autoresponder step in Sendy for real.