Plugin Directory

Changeset 218566


Ignore:
Timestamp:
03/17/2010 02:44:39 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

    r214456 r218566  
    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.1
     6Version: 1.2
    77Author: GKauten
    88Author URI: http://www.gkauten.com
     
    330330     
    331331      <h3>Example Transaction</h3>
    332       <p><?php echo get_option("cri_transurl")."?".get_option("cri_wp_username_as")."=___________&".get_option("cri_wp_email_as")."=___________&".get_option("cri_wp_password_as")."=___________".get_option("cri_special_params"); ?></p>
     332      <p><?php echo get_option("cri_transurl")."?".get_option("cri_special_params"); ?></p>
    333333
    334334      <p style="padding: 20px;">
     
    414414    $profile_field_ids = explode( ',', $_POST['signup_profile_field_ids'] );
    415415    // Loop through the posted fields formatting any datebox values then add to $data
    416     $data = "";
     416    $data = array();
    417417    foreach((array) $profile_field_ids as $field_id) {
    418418      if(!isset($_POST['field_' . $field_id])) {
     
    421421        }
    422422      }
    423       $data .= "field_" . $field_id . "=" . $_POST['field_' . $field_id] . "&";
     423      $data["field_" . $field_id] = $_POST['field_' . $field_id];
    424424    }
    425425  }
     
    440440function cri_cross_register($user_login, $user_email, $user_pass, $data = null) {
    441441  global $cri_system;
    442  
    443442  // Exit if Transaction URL is empty
    444443  if(get_option("cri_transurl") == "" || get_option("cri_transurl") === false) return;
    445  
    446444  // Encryption
    447445  switch(get_option("cri_encrypt")) {
     
    452450      break;
    453451  }
    454  
    455452  // Initiate Appropriate System Variables
    456   if($cri_system == "word") {
    457     $username_as = get_option("cri_wp_username_as");
    458     $email_as = get_option("cri_wp_email_as");
    459     $password_as = get_option("cri_wp_password_as");
    460   } elseif($cri_system == "buddy") {
     453  if($cri_system == "buddy") {
    461454    $username_as = get_option("cri_bp_username_as");
    462455    $email_as = get_option("cri_bp_email_as");
    463456    $password_as = get_option("cri_bp_password_as");
    464457  } else {
    465     $username_as = "username";
    466     $email_as = "email";
    467     $password_as = "password";
    468   }
    469  
     458    $username_as = get_option("cri_wp_username_as");
     459    $email_as = get_option("cri_wp_email_as");
     460    $password_as = get_option("cri_wp_password_as");
     461  }
    470462  // Begin Cross Registration
    471   $params = "";
    472   $params .= $username_as . "=" . $user_login . "&";
    473   $params .= $email_as . "=" . $user_email . "&";
    474   $params .= $password_as . "=" . $user_pass . "&";
    475  
     463  $params = array();
     464  $params[$username_as] = $user_login;
     465  $params[$email_as] = $user_email;
     466  $params[$password_as] = $user_pass;
    476467  // Add Extra Data Fields
    477468  if($data) {
    478     $params .= $data;
    479   }
    480  
     469    $params = array_merge($params, $data);
     470  }
    481471  // Add Special Parameters
    482472  if(get_option("cri_special_params") != "") {
    483     $params .= get_option("cri_special_params");
    484   }
    485  
    486   $r = cri_http(get_option("cri_transurl") . "?" . $params);
     473    $special = get_option("cri_special_params");
     474    if(strstr($special, "&")) {
     475      // Assume Multiple Params
     476      $temp_spec = array();
     477      $temp_spec = explode("&", $special);
     478      if(count($temp_spec)) {
     479        foreach($temp_spec as $spec) {
     480          $params[substr($spec, 0, strpos($spec, "="))] = substr($spec, strpos($spec, "=") + 1);
     481        }
     482      }
     483    } else {
     484      $params[substr($special, 0, strpos($special, "="))] = substr($special, strpos($special, "=") + 1);
     485    }
     486  }
     487  $r = cri_http(get_option("cri_transurl"), $params);
    487488}
    488489
     
    491492/************************************/
    492493
    493 function 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;
     494function cri_http($url, $post_fields = "") {
     495  $postfields = array();
     496  if(count($post_fields)) {
     497    foreach($post_fields as $i => $f) {
     498      $postfields[] = urlencode($i) . '=' . urlencode($f);
     499    }
     500  }
     501  $fields = implode('&', $postfields);
     502  $opts = array(
     503    'http'=>array(
     504      'method' => "POST",
     505      'header' => "Content-Type: application/x-www-form-urlencoded\r\n" .
     506                  "Content-Length: " . strlen($fields) . "\r\n\r\n" .
     507                  $fields
     508    )
     509  );
     510  $context = stream_context_create($opts);
     511  $fp = @fopen($url, 'rb', false, $context);
     512  @fclose($fp);
    513513}
    514514
  • cross-registration-integration/trunk/readme.txt

    r214456 r218566  
    55Requires at least: 2.8.6
    66Tested up to: 2.9.2
    7 Stable tag: 1.1
     7Stable tag: 1.2
    88
    99Integrates with the WordPress registration process to assist with the registration process for other systems.
     
    2424fields are transmitted to the Transaction URL once a user completes the BuddyPress controlled registration page.
    2525
    26 Version 1.1 introduces one new feature and an enhancement to an existing feature. The amount of delay that was
    27 previously experienced while waiting for the call to the Transaction URL has been optimized to only add an
     26Version 1.1 introduced 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 was optimized to only add an
    2828additional second or two to the overall load time. As for new features, on BuddyPress installations the profile
    29 fields will now also be passed along. However, because of the dynamic nature of these fields there is not a
     29fields are also passed along. However, because of the dynamic nature of these fields there is not a
    3030feasible way to assign new names to them as they pass so they will maintain their original form names (i.e -
    3131field_1, field_2, etc... going down as an ordered list).
     32
     33Version 1.2 further optimizes the methods by which the Transaction URL is called and respective form data passed.
     34Because the plugin uses a POST method, the receiving server should be expecting a POST as well. A later version
     35is planned to allow for the selection of either a GET or POST transaction. This version also confirms the ability
     36to work with the infamous MailChimp mailing system. For details regarding how to integrate with your MailChimp
     37list, please refer to http://www.gkauten.com/cross-registration-integration-meets-mailchimp.
    3238
    3339If you find this plugin useful, please donate. Donations help pay for the massive amount of energy drinks
     
    6672== Changelog ==
    6773
     74= 1.2 =
     75* Improved transaction post method.
     76* Verified ability to integrate with the MailChimp email marketing system.
     77
    6878= 1.1 =
    6979* Reduced the amount of time required to process the Transaction URL transmission on registration.
     
    8999== Upgrade Notice ==
    90100
     101= 1.2 =
     102This version further enhanced the Transaction URL call methods and optimized field delivery. It also confirms integration with the MailChimp email marketing system.
     103
    91104= 1.1 =
    92105This version reduces the amount of time required to process the Transaction URL transmission on registration and includes the Profile fields for BuddyPress installations.
Note: See TracChangeset for help on using the changeset viewer.