9c8c6e0d by Jeff Balicki

remove maindrill unsub

Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent 2d58e81d
...@@ -728,49 +728,3 @@ function current_url() ...@@ -728,49 +728,3 @@ function current_url()
728 return $pageURL; 728 return $pageURL;
729 } 729 }
730 730
731
732 // Custom function to handle unsubscribe events
733 function handle_unsubscribe_event($data) {
734
735 $unsubscribe_data = json_decode($data, true);
736
737 $users = get_users(array(
738 'number' => 1,
739 'meta_key' => 'home_email',
740 'meta_value' => $unsubscribe_data['email'],
741 'meta_compare' => '=',
742 ));
743 if(!$users){
744 $users = get_users(array(
745 'number' => 1,
746 'meta_key' => 'work_email',
747 'meta_value' => $unsubscribe_data['email'],
748 'meta_compare' => '=',
749 ));
750 }
751 if($users){
752 update_user_meta($users[0]->ID, 'email_address_preference', 'none');
753 }
754 }
755
756 // Hook into the unsubscribe event
757 add_action('unsubscribe_event', 'handle_unsubscribe_event');
758
759 // Endpoint to receive webhook notifications
760 function my_unsubscribe_mandrill_endpoint() {
761 // Check if request is a POST request
762 if ($_SERVER['REQUEST_METHOD'] === 'POST') {
763 // Process webhook data
764 $data = file_get_contents('php://input');
765 // Trigger the custom action hook with the webhook data
766 do_action('unsubscribe_event', $data);
767 }
768 }
769
770 // Register the webhook endpoint
771 add_action('rest_api_init', function () {
772 register_rest_route('cicbv-api/v1', '/unsubscribe-mandrill', array(
773 'methods' => 'POST',
774 'callback' => 'my_unsubscribe_mandrill_endpoint',
775 ));
776 });
...\ No newline at end of file ...\ No newline at end of file
......