Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add to mu-plugins folder, auto add every new user to a sendy list. Works with default WordPress and Woocommerce registrations.
<?php
add_action( 'user_register', 'add_user_to_sendy_list' );
function add_user_to_sendy_list( $user_id ) {
$list = 'SENDY_LIST_ID';
$url = 'http://SENDY_INSTALL_URL/subscribe';
$user = get_userdata( $user_id );
$email = $user->data->user_email;
$name = $user->data->user_nicename;
$args = array(
'body' => array(
'email' => $email,
'name' => $name,
'boolean' => true,
'list' => $list
)
);
$result = wp_remote_post( $url, $args );
}
@imkane

This comment has been minimized.

Copy link

imkane commented Dec 7, 2016

Do you know if this can be modified to subscribe ALL WooCommerce purchases to a Sendy list? Because customers are allowed to checkout as guests and not create a WP account, although the system obviously stores their name, email, etc.

@rodeista

This comment has been minimized.

Copy link

rodeista commented May 23, 2017

Hi, thanks a lot! Works great. Do you have idea, how to use it in combination with get_user_meta and custom field in sendy please?

@mattkaz

This comment has been minimized.

Copy link

mattkaz commented Mar 28, 2018

This is great, thank you!
However, I was wondering if you might have any idea on how to make it unsubscribe a user from the same Sendy mailing list, when deleting that user from the WP users? So basically, adding the reverse of what it does now.

Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.