Plugin Directory

Changeset 214456


Ignore:
Timestamp:
03/07/2010 03:00:47 AM (16 years ago)
Author:
GKauten
Message:
 
Location:
cross-registration-integration
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • cross-registration-integration/trunk/cross-registration-integration.php

    r213321 r214456  
    44Plugin URI: http://www.gkauten.com/cross-registration-integration
    55Description: Integrates with the WordPress registration process to assist with the registration process for other systems. Meaning, this plugin will simultaneously transmit the user's information entered in to your WordPress registration page to a URL you specify which can then handle creating a duplicate user account within your other systems on your website.
    6 Version: 1.0
     6Version: 1.1
    77Author: GKauten
    88Author URI: http://www.gkauten.com
     
    2626*/
    2727
     28// Used to Define WordPress or BuddyPress in Certain  Functions
    2829global $cri_system;
    2930
     
    408409    }
    409410  }
     411 
     412  // Check for Extra Profile Fields
     413  if(!empty( $_POST['signup_profile_field_ids'])) {
     414    $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
     415    // Loop through the posted fields formatting any datebox values then add to $data
     416    $data = "";
     417    foreach((array) $profile_field_ids as $field_id) {
     418      if(!isset($_POST['field_' . $field_id])) {
     419        if(isset($_POST['field_' . $field_id . '_day'])) {
     420          $_POST['field_' . $field_id] = strtotime($_POST['field_' . $field_id . '_day'] . $_POST['field_' . $field_id . '_month'] . $_POST['field_' . $field_id . '_year']);
     421        }
     422      }
     423      $data .= "field_" . $field_id . "=" . $_POST['field_' . $field_id] . "&";
     424    }
     425  }
    410426
    411427  // Transmit Information
    412   cri_cross_register($user_login, $user_email, $user_pass);
     428  cri_cross_register($user_login, $user_email, $user_pass, $data);
    413429}
    414430
     
    422438/************************************/
    423439
    424 function cri_cross_register($user_login, $user_email, $user_pass) {
     440function cri_cross_register($user_login, $user_email, $user_pass, $data = null) {
    425441  global $cri_system;
    426442 
     
    453469 
    454470  // Begin Cross Registration
    455   $params = array(
    456     $username_as => $user_login,
    457     $email_as => $user_email,
    458     $password_as => $user_pass
    459   );
    460 
     471  $params = "";
     472  $params .= $username_as . "=" . $user_login . "&";
     473  $params .= $email_as . "=" . $user_email . "&";
     474  $params .= $password_as . "=" . $user_pass . "&";
     475 
     476  // Add Extra Data Fields
     477  if($data) {
     478    $params .= $data;
     479  }
     480 
     481  // Add Special Parameters
    461482  if(get_option("cri_special_params") != "") {
    462     if(strstr(get_option("cri_special_params"), "&")) {
    463       // Found "&" - Assuming Multiple Keys
    464       $fields = explode('&', get_option("cri_special_params"));
    465       if(count($fields)) {
    466         $field_set = array();
    467         foreach($fields as $field) {
    468           $field_set = explode("=", $field);
    469           $params[$field_set[0]] = $field_set[1];
    470         }
    471       }
    472     } else {
    473       // No "&" but Content Found - Assuming One Key
    474       $field_set = explode("=", get_option("cri_special_params"));
    475       $params[$field_set[0]] = $field_set[1];
    476     }
    477   }
    478 
    479   $r = cri_post(get_option("cri_transurl"), $params);
    480 }
    481  
    482 /************************************/
    483 /* Post Registration Method         */
    484 /************************************/
    485 
    486 function cri_post($url, $fields) {
    487   return cri_request(true, $url, $fields);
    488 }
    489 
    490 /************************************/
    491 /* Request Registration Method      */
    492 /************************************/
    493 
    494 function cri_request($post, $url, $fields) {
    495   $postfields = array();
    496   if(count($fields)) {
    497     foreach($fields as $i => $f) {
    498       $postfields[] = urlencode($i) . '=' . urlencode($f);
    499     }
    500   }
    501   $fields = implode('&', $postfields);
    502   return cri_http($post ? 'POST' : 'GET', $url, $fields);
    503   $ch = curl_init($url);
    504   $ck = array();
    505   $headers = array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11", "Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "Accept-Language: en-us,en;q=0.5", "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7", "Keep-Alive: 300", "Connection: keep-alive");
    506   curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    507   if($post) {
    508     curl_setopt($ch, CURLOPT_POST, true);
    509     $postfields = array();
    510     if(count($fields)) {
    511       foreach($fields as $i => $f) {
    512         $postfields[] = urlencode($i) . '=' . urlencode($f);
    513       }
    514     }
    515     $fields = implode('&', $postfields);
    516     curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
    517     $headers[] = "Content-Type: application/x-www-form-urlencoded";
    518     $headers[] = "Content-Length: " . strlen($fields);
    519   }
    520   curl_setopt($ch, CURLOPT_HEADER, $this->headers);
    521   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    522   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    523   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    524   $res = curl_exec($ch);
    525   curl_close($ch);
    526   return $res;
    527 }
    528 
    529 /************************************/
    530 /* Registration Process Hooks       */
    531 /************************************/
    532 
    533 function cri_http($method, $url, $data = null) {
    534   preg_match('~http://([^/]+)(/.*)~', $url, $subs);
    535   $host = $subs[1];
    536   $uri = $subs[2];
    537   $header .= "$method $uri HTTP/1.1\r\n";
    538   $header .= "Host: $host\r\n";
    539   $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
    540   $header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
    541   $fp = fsockopen ($host, 80, $errno, $errstr, 30);
    542   if($fp) {
    543     fputs($fp, $header . $data);
    544     $result = '';
    545     while(!feof($fp)) $result .= fgets($fp, 4096);
    546   }
    547   fclose($fp);
    548   return $result;
     483    $params .= get_option("cri_special_params");
     484  }
     485 
     486  $r = cri_http(get_option("cri_transurl") . "?" . $params);
     487}
     488
     489/************************************/
     490/* Registration Post Process        */
     491/************************************/
     492
     493function cri_http($url) {
     494  $params = array('http' => array(
     495    'method' => 'post',
     496    'content' => strstr($url, "?")
     497  ));
     498
     499  $ctx = stream_context_create($params);
     500  $fp = @fopen($url, 'rb', false, $ctx);
     501
     502  if (!$fp) {
     503    exit("Problem with $url, $php_errormsg");
     504  }
     505
     506  $response = @stream_get_contents($fp);
     507
     508  if ($response === false) {
     509    exit("Problem reading data from $url, $php_errormsg");
     510  }
     511 
     512  return $response;
    549513}
    550514
  • cross-registration-integration/trunk/readme.txt

    r213323 r214456  
    55Requires at least: 2.8.6
    66Tested up to: 2.9.2
    7 Stable tag: 1.0
     7Stable tag: 1.1
    88
    99Integrates with the WordPress registration process to assist with the registration process for other systems.
     
    2020triggering external functions.
    2121
    22 As of version 1.0, Cross Registration Integration is enabled to work with BuddyPress sites as well. Upon enabling
     22Version 1.0 is now enabled to work with BuddyPress sites allowing you to maintain the same functionality. Upon enabling
    2323the plugin, there will be a new set of options within the plugin administration panel allowing you to choose which
    2424fields are transmitted to the Transaction URL once a user completes the BuddyPress controlled registration page.
     25
     26Version 1.1 introduces one new feature and an enhancement to an existing feature. The amount of delay that was
     27previously experienced while waiting for the call to the Transaction URL has been optimized to only add an
     28additional second or two to the overall load time. As for new features, on BuddyPress installations the profile
     29fields will now also be passed along. However, because of the dynamic nature of these fields there is not a
     30feasible way to assign new names to them as they pass so they will maintain their original form names (i.e -
     31field_1, field_2, etc... going down as an ordered list).
    2532
    2633If you find this plugin useful, please donate. Donations help pay for the massive amount of energy drinks
     
    5966== Changelog ==
    6067
     68= 1.1 =
     69* Reduced the amount of time required to process the Transaction URL transmission on registration.
     70* Added BuddyPress Profile fields to the Transaction URL transmission on registration.
     71
    6172= 1.0 =
    6273* Added support for the BuddyPress social networking plugin.
     
    7889== Upgrade Notice ==
    7990
     91= 1.1 =
     92This version reduces the amount of time required to process the Transaction URL transmission on registration and includes the Profile fields for BuddyPress installations.
     93
    8094= 1.0 =
    8195This version added support for the BuddyPress social networking plugin and a new special parameters field.
Note: See TracChangeset for help on using the changeset viewer.