Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
9c8c6e0d
authored
2024-04-15 14:22:58 -0400
by
Jeff Balicki
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
remove maindrill unsub
Signed-off-by: Jeff <jeff@gotenzing.com>
1 parent
2d58e81d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
46 deletions
com/Notifications/Notifications.php
com/Notifications/Notifications.php
View file @
9c8c6e0
...
...
@@ -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
...
...
Please
register
or
sign in
to post a comment