API / Notifications s2_signup_notification Webhook
-
I am trying to code an API / Notification webhook for Signup Notifications. I found the excellent knowledge base article written at https://s2member.com/kb-article/building-an-api-notification-handler-webhook/
That example shows you how to fire a webhook for Payment Notifications using the API
The issue I’m running into is I cannot seem to find the trigger for a Signup Notification.
In the example webhook the variable s2_payment_notification is tested to see if its equal to yes
I’ve tried using s2_signup_notification in its place, but it seems that s2_signup_notification may not be a valid variable.
If one was to want to write a custom webhook for Signup Notification or any other API Notification OTHER THAN payment notifications, what $GET variable would you target?
I’ve search the knowledgebase and I’ve not turned up anything. I tried searching the GitHub repo and I’ve found nothing related to s2_signup_notification anywhere. I’m at a loss for what variable to use.
Here is the code I used while trying to fire a Signup Notification webhook
<?php add_action('init', 's2_signup_notification'); function s2_signup_notification() { if(!empty($_GET['s2_signup_notification']) && $_GET['s2_signup_notification'] === 'yes') // ↑ In my URL, I have <code>?s2_signup_notification=true</code>, that's what I'm looking for here. { if(!empty($_GET['user_id']) && !empty($_GET['item_number'])) // In my URL, I have <code>&user_id=%%user_id%%&item_number=%%item_number%%</code>, that's what I'm looking for here. { $user_id = (integer)$_GET['user_id']; // I'm expecting an integer in this value. $item_number = (string)$_GET['item_number']; // I'm expecting a string in this value. $user = new WP_User($user_id); // Get a WordPress User object instance so I can work with this customer. // Here I might perform any number of tasks related to this user. Such as creating a user option value in WordPress. //update_user_option($user_id, 'my_custom_data_for_this_user', $item_number); // I could also collect details about this user, by accessing properties of my WP_User object instance. $first_name = $user->first_name; $last_name = $user->last_name; $email = $user->user_email; $username = $user->user_login; // I can also pull s2Member option values related to this user. $s2member_subscr_id = get_user_option('s2member_subscr_id', $user_id); $s2member_custom_fields = get_user_option('s2member_custom_fields', $user_id); $s2member_custom = get_user_option('s2member_custom', $user_id); $s2member_registration_ip = get_user_option('s2member_registration_ip', $user_id); $s2member_paid_registration_times = get_user_option('s2member_paid_registration_times', $user_id); $s2member_first_payment_txn_id = get_user_option('s2member_first_payment_txn_id', $user_id); $s2member_last_payment_time = get_user_option('s2member_last_payment_time', $user_id); $s2member_auto_eot_time = get_user_option('s2member_auto_eot_time', $user_id); $s2member_file_download_access_log = get_user_option('s2member_file_download_access_log', $user_id); // I could also log this transaction, by creating a log entry in a static text file on-site. file_put_contents(WP_CONTENT_DIR.'/plugins/s2member-logs/my.log', 'Signup Notification Received for User ID: '.$user_id."\n", FILE_APPEND); } exit; // We can exit here. There's no reason to continue loading WordPress in this case. } }
- The topic ‘API / Notifications s2_signup_notification Webhook’ is closed to new replies.