Statistics: Posted by Cristián Lávaque — December 19th, 2011, 4:30 am
$user = wp_get_current_user();
$current_user = json_decode(S2MEMBER_CURRENT_USER_FIELDS, true);
//test to see if they already have the custom capability 'request'
if(current_user_can("access_s2member_ccap_request")){
echo "You already have added your details to the database";
}
//if not then run the database request
else
{
$prepost['action'] = "addUser";
$prepost['email'] = $current_user['email'];
$prepost['forename'] = $current_user['first_name'];
$prepost['surname'] = $current_user['last_name'];
$prepost['company'] = $current_user['type_name'];
$prepost['type'] = $current_user['user_type'];
$prepost['title'] = $current_user['role'];
$prepost['phone'] = $current_user['phone'];
$prepost['dob'] = $current_user['dob'];
$prepost['add1'] = $current_user['address1'];
$prepost['add2'] = $current_user['address2'];
$prepost['town'] = $current_user['city'];
$prepost['county'] = $current_user['state'];
$prepost['country'] = $current_user['country'];
$prepost['postCode'] = $current_user['zip'];
//traverse array and prepare data for posting (key1=value1)
foreach ( $prepost as $key => $value)
{
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
//print_r($prepost);
$post_string = implode ('&', $post_items);
//create cURL connection
//echo $post_string;
$curl_connection =
curl_init('http://**removed**');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
$splitResult = explode('-', $result);
//The status is whether it worked or it didnt, can be 'False' or 'True'
$status = $splitResult[0];
//The message is what to display to the user
$message = $splitResult[1];
if($status == 'True')
{
//If everything went well
echo $message;
echo "
Please check your email for your user details!
";
}
else
{
//something went wrong - tell the user
echo $message;
}
//print_r(curl_getinfo($curl_connection));
//close the connection
curl_close($curl_connection);
//now that they have added details to database, add custom capability 'request' so they are unable to run the script again
$user->add_cap("access_s2member_ccap_request");
}
Statistics: Posted by wibbsy — December 6th, 2011, 6:45 am
Has this member already made a request to this database at some point in the past?
Yes > Don't execute DB request > return an error ("Data was already provided on 01/11/11"); or
No > Execute DB request > return data > Update profile field 'request' to true.
Statistics: Posted by wibbsy — December 6th, 2011, 4:44 am
Statistics: Posted by Cristián Lávaque — September 2nd, 2011, 11:38 pm
Statistics: Posted by fgamimarlik — September 2nd, 2011, 3:24 pm
Statistics: Posted by fgamimarlik — September 2nd, 2011, 6:13 am
Statistics: Posted by Cristián Lávaque — August 29th, 2011, 7:14 pm
Statistics: Posted by fgamimarlik — August 29th, 2011, 4:18 am
Statistics: Posted by fgamimarlik — August 29th, 2011, 2:04 am
Statistics: Posted by YourOnlineGuy — June 25th, 2011, 12:18 pm
Statistics: Posted by Jason Caldwell — June 25th, 2011, 12:34 am
Warning: Cannot modify header information - headers already sent by (output started at /home/gbpmxnig/public_html/youronlineguy.com/members/wp-content/plugins/s2member/includes/syscon.inc.php:1) in /home/gbpmxnig/public_html/youronlineguy.com/members/wp-includes/pluggable.php on line 897
Statistics: Posted by YourOnlineGuy — June 22nd, 2011, 10:39 am
/*
Backward compatibility for "custom_reg_fields", which was re-formatted in v3.2.7 to a JSON encoded array of fields.
*/
if ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] && !$options["custom_reg_fields"] && !is_array (json_decode ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"])))
{
$fields = array (); /* Initialize the new array of field objects. */
/**/
foreach (preg_split ("/[\r\n\t;,]+/", $GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"]) as $field)
{
$required = (preg_match ("/\*/", $field)) ? 'yes' : 'no';
$editable = (preg_match ("/\^/", $field)) ? 'no' : 'yes';
/**/
if ($field = trim ($field, "^* \t\n\r\0\x0B"))
{
$fields[] = array ("id" => $field, "label" => $field, "type" => "text", "options" => "", "expected_format" => "", "required" => $required, "levels" => "all", "editable" => $editable, "classes" => "", "styles" => "", "attrs" => "");
}
}
/**/
$GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_fields"] = json_encode ($fields);
/**/
unset ($une, $editable, $req, $required, $field, $fields);
}
Statistics: Posted by Jason Caldwell — June 22nd, 2011, 3:12 am
Warning: Invalid argument supplied for foreach() in /home/gbpmxnig/public_html/youronlineguy.com/members/wp-content/plugins/s2member/includes/classes/custom-reg-fields.inc.php on line 293
Statistics: Posted by YourOnlineGuy — June 21st, 2011, 7:04 pm
Statistics: Posted by YourOnlineGuy — June 20th, 2011, 10:44 pm
<?php
/*
Setting options dynamically for Custom Registration Fields.
*/
add_action ("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_options");
function my_dynamic_field_options ($vars = array ())
{
$_field = &$vars["__refs"]["_field"]; /* By "reference". */
/* See: http://www.php.net/manual/en/language.references.spot.php. */
/**/
if ($_field["id"] === "country_code")
{
$_field["options"] = "US|United States|default" . "\n";
$_field["options"] .= "CA|Canada" . "\n";
$_field["options"] .= "VI|Virgin Islands (U.S.)";
}
}
/*
Setting a default value for Custom Registration Fields.
*/
add_action ("ws_plugin__s2member_before_custom_field_gen", "my_dynamic_field_values");
function my_dynamic_field_values ($vars = array ())
{
$references = &$vars["__refs"]; /* Array of variable "references". */
$_field = &$vars["__refs"]["_field"]; /* By "reference". */
/* See: http://www.php.net/manual/en/language.references.spot.php. */
/**/
if ($_field["id"] === "country_code")
{
if (empty ($references["_submission"]) && empty ($references["_value"]))
/* If a form was not just submitted. And, there is no default value. */
$references["_value"] = "CA"; /* Set the default value. */
}
}
?>
Statistics: Posted by Jason Caldwell — March 26th, 2011, 8:02 pm