• Resolved MALiberato

    (@maliberato)


    Hi! First of all thank you for the plugin ??
    I need to do a tricky thing… I have to send an email every x-days to people who didn’t buy a product (anual subscription). The problem is that they can buy this offline, which means that not every purchase is registered in woocommerce.
    My solution to have everything in the same place was creating a custom field for the users that is empty or false (unpayed or payed). I think the easiest way to do this is subscribe everyone and create a function where everytime the custom field is updated the user is unsubscribed is the field is not empty. Can you help me with this?

    https://www.ads-software.com/plugins/email-subscribers/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author storeapps

    (@storeapps)

    @maliberato,

    Using Email Subscribers, you can send an notification immediately when a post is published.

    But if you want to send x-days or on products, you can have a check on Klawoo which is our complete Email Marketing solution. Using Klawoo Connector you can sync your WooCommerce orders and send notification after any number of days.

    Thread Starter MALiberato

    (@maliberato)

    We have online and in person sales, it won’t work. I only need to know how to unsubscribe a person in php, I can do the rest.

    Plugin Author storeapps

    (@storeapps)

    @maliberato,

    Go to email-subscribers/classes/ & open es-sendmail.php
    In that file, search for the function es_sendmail, in that locate this line :
    $unsublink = $settings['es_c_unsublink'];

    There you will find a block of code for creating the unsubscribe link in php.

    Thread Starter MALiberato

    (@maliberato)

    Thank you! I’ll try

    Plugin Author storeapps

    (@storeapps)

    @maliberato,

    You are welcome ??

    Thread Starter MALiberato

    (@maliberato)

    I didn’t use that but it’s working… for anyone who want to do the same:

    //hook profile updates
    add_action( 'profile_update', 'my_profile_update', 10, 2 );
    
    //create the function. $user_id is the updated user id
    function my_profile_update( $user_id, $old_user_data ) {
    
        //get the custom field data and verify if it's empty
        $user_info = get_userdata($user_id);
        $custom_field = $user_info->custom_field;
        if (!empty($custom_field)){
    
            //if the custom_field is empty, find user email
            $user_email = $user_info->user_email;
    
                //connect to DB
                global $wpdb;
    
                //delete row where the email exists
                $wpdb->delete( 'wp_es_emaillist', array( 'es_email_mail' => $user_email ) );
    
        }
    
    }

    If anyone has a better solution please tell me

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add and remove subscribers programmatically’ is closed to new replies.