-
-
Save AminulBD/5762e38fa6bad5d5ebae7de6061b372e 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 hidden or 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 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment