Statistics: Posted by stefanogaruti — November 22nd, 2011, 3:25 am
I would try to stick with s2Member's API Notifications on this. You will save yourself some time and everything is better documented for this approach. Trying to use lots of Hooks in this regard can become too complex, and is subject to change slightly in future releases of s2Member.
As first step I would like to create a new "Customer" in ZOHO Invoice any time a new user register on S2Member. Later I'll add the possibility to create a new Invoice any time a user make a payment.
I would use the S2Member API/notification fields, but the ZOHO's API requires this actions to be POST and not GET.
<?php
$_3rd_party_service = /* Change this. */ "http://3rd-party-service.com/api";
$response = curlpsr ($_3rd_party_service, http_build_query (trim_deep (stripslashes_deep ($_GET))));
/*
---- Do NOT edit anything below, unless you know what you're doing. --------------------------------------------------------*/
/*
Recursive function that trims deeply.
*/
function trim_deep ($value = FALSE)
{
return is_array ($value) ? array_map ("trim_deep", $value) : trim ((string)$value);
}
/*
Recursive function that strips slashes deeply.
*/
function stripslashes_deep ($value = FALSE)
{
return is_array ($value) ? array_map ("stripslashes_deep", $value) : stripslashes ((string)$value);
}
/*
cURL operation for posting data and reading response.
*/
function curlpsr ($url = FALSE, $postvars = array (), $max_con_secs = 20, $max_stream_secs = 20, $headers = array ())
{
if (($url = trim ($url)) && ($c = curl_init ()))
{
if (is_array ($postvars)) /* Because cURL can't deal with complex arrays. */
/* Since cURL can't deal with complex arrays, we force this to a query string. */
$postvars = http_build_query ($postvars);
/**/
curl_setopt_array ($c, /* Configure options. */
array (CURLOPT_URL => $url, CURLOPT_POST => true,/**/
CURLOPT_CONNECTTIMEOUT => $max_con_secs, CURLOPT_TIMEOUT => $max_stream_secs, /* Initial connection & stream seconds. */
CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => $headers, CURLOPT_POSTFIELDS => $postvars,/**/
CURLOPT_FOLLOWLOCATION => ($follow = (!ini_get ("safe_mode") && !ini_get ("open_basedir"))), CURLOPT_MAXREDIRS => (($follow) ? 5 : 0),/**/
CURLOPT_ENCODING => "", CURLOPT_VERBOSE => false, CURLOPT_FAILONERROR => true, CURLOPT_FORBID_REUSE => true, CURLOPT_SSL_VERIFYPEER => false));
/**/
$o = trim (curl_exec ($c));
/**/
curl_close($c);
}
/**/
return (!empty ($o)) ? $o : false;
}
?>
Statistics: Posted by Jason Caldwell — November 21st, 2011, 2:09 pm
Statistics: Posted by Cristián Lávaque — November 21st, 2011, 2:56 am
Statistics: Posted by stefanogaruti — November 18th, 2011, 6:59 am
<?php
function get_s2_usermeta ($id)
{
//Get the user data <http://codex.wordpress.org/Function_Reference/get_userdata/>
$user = get_userdata ($id);
//Usermeta value for s2Member registration IP Address
$registration_ip = get_user_meta ($id, 'wp_s2member_registration_ip');
//usermeta value for s2Member Login Counter ( Not useful for this )
$logins = get_user_meta ($id, 'wp_s2member_login_counter');
}
add_action ('user_register', 'get_s2_usermeta');
?>
Statistics: Posted by Bruce C — November 16th, 2011, 11:46 am
Statistics: Posted by stefanogaruti — November 16th, 2011, 9:46 am