9c8c6e0d by Jeff Balicki

remove maindrill unsub

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 2d58e81d
......@@ -728,49 +728,3 @@ function current_url()
return $pageURL;
}
// Custom function to handle unsubscribe events
function handle_unsubscribe_event($data) {
$unsubscribe_data = json_decode($data, true);
$users = get_users(array(
'number' => 1,
'meta_key' => 'home_email',
'meta_value' => $unsubscribe_data['email'],
'meta_compare' => '=',
));
if(!$users){
$users = get_users(array(
'number' => 1,
'meta_key' => 'work_email',
'meta_value' => $unsubscribe_data['email'],
'meta_compare' => '=',
));
}
if($users){
update_user_meta($users[0]->ID, 'email_address_preference', 'none');
}
}
// Hook into the unsubscribe event
add_action('unsubscribe_event', 'handle_unsubscribe_event');
// Endpoint to receive webhook notifications
function my_unsubscribe_mandrill_endpoint() {
// Check if request is a POST request
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Process webhook data
$data = file_get_contents('php://input');
// Trigger the custom action hook with the webhook data
do_action('unsubscribe_event', $data);
}
}
// Register the webhook endpoint
add_action('rest_api_init', function () {
register_rest_route('cicbv-api/v1', '/unsubscribe-mandrill', array(
'methods' => 'POST',
'callback' => 'my_unsubscribe_mandrill_endpoint',
));
});
\ No newline at end of file
......