Skip to content

Instantly share code, notes, and snippets.

@MarceloPedra
Forked from Pross/sendy.php
Created April 30, 2016 01:34
Show Gist options
  • Save MarceloPedra/cbaff8840f4904cd3d7b13fec2857fc2 to your computer and use it in GitHub Desktop.
Save MarceloPedra/cbaff8840f4904cd3d7b13fec2857fc2 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.
<?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