Hi Cheryl,
s2Member currently does not support all of the information that you need, as it is meant to be a way to connect to Affiliate programs and other sotware outside of WordPress that would have no use for this information.
Therefore, instead of using API Notifications, I recommend just using the core WordPress functionality to get the user’s data, and querying PayPal for subscription info.
Instead of using s2Member’s API Notifications it may be easier to just hook into WordPress’s user_register hook. This hook should give you all the info you need to send your email. Make sure to use a lower priority than s2Member, however. s2Member uses the default 10 priority, so using something like this should work, in a Must-Use Plugin within your /wp-content/mu-plugins/ directory (create it if you don’t have it):
<?php
add_action('user_register', 's2hack_user_register_email', 20, 1);
function s2hack_user_register_email($id) {
$user = new WP_User($id);
$subscr_id = get_user_option('s2member_subscr_id', $id); // User's current PP subscription ID.
$paypal = array ('METHOD' => 'GetRecurringPaymentsProfileDetails', 'PROFILEID' => $subscr_id); // API call configuration.
if (($paypal = c_ws_plugin__s2member_paypal_utilities::paypal_api_response ($paypal)) && !$paypal['__error'])
$type = $paypal['BILLINGPERIOD']; // The billing period for the
$to = $user->user_email; // 'cdelcolliano@earthlink.net' ;
$headers[] = 'From: Inside Music Media <jdelcolliano@earthlink.net>';
$headers[] = 'Cc: paul@wordfresh.com';
$subject = 'New Member Notification';
### USER DETAILS ###
$first_name = $user->first_name;
$last_name = $user->last_name;
$email = $user->user_email;
### USER DETAILS ###
if($type === 'Month') {
// This is a monthly subscriber.
}
elseif($type === 'Year') {
// This is a yearly subsriber.
}
}
The user_register
code gives you the user’s ID, which allows you to then get all of their info by creating a new WP_User()
. Find info on this at:
http://codex.wordpress.org/Class_Reference/WP_User
This code also performs a query to PayPal to find info on their billing cycle. Find info on the data recieved here:
https://www.x.com/developers/paypal/documentation-tools/api/getrecurringpaymentsprofiledetails-api-operation-nvp
This code would only work for users that are creating an account. So if you have free registration enabled, or if you have the ability for users to upgrade their accounts, this would need to be tweaked a bit.