Created
April 26, 2016 19:14
-
-
Save Pross/3ff9f68fea20dcdc8845919dc51de90d to your computer and use it in GitHub Desktop.
Add to mu-plugins folder, auto add every new user to a sendy list. Works with default WordPress and Woocommerce registrations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); | |
} |
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?
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!
Great work, can we use it ONLY if the user has verified email upon registration in WordPress? I don't want to send an invalidated email to sendy to avoid SES health issues..
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.