We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36575
    • 104 Posts
    rachelmarama1 Reply #1, 13 years ago
    hi,
    Not sure if this is the right place to add this, but I have a question about auto submitting data to another site, in this case, iContact.

    My client wants to have their users automatically added to iContact when they are registered on their website. I have the login/registration all working.

    I think I would do this with a post-hook, but I’m not sure how I would code the php to have the data I have just gathered then submitted to iContact.

    Has anyone done this, or something like this?

    http://astrabridal.123abc.co.nz is the test site I am working on.

    thanks,
    Rachel
      • 36575
      • 104 Posts
      rachelmarama1 Reply #2, 13 years ago
      hi again,

      I figure I need some php as a posthook. I am calling a post hook sendiContact, and i have this in my snippet, based on this post.

      I know it’s wrong; I’m just hoping someone with more php / modx knowledge than I have can tell me where it’s wrong.


      <?php
      define(’POSTURL’, ’https://app.icontact.com/icp/signup.php’);
      define(’POSTVARS’, ’listID=16599&specialid:16599=AE7L&clientid=162410&formid=1167&reallistid=1&doubleopt=0&feilds_email&feilds_fname&feilds_lname’); // POST VARIABLES TO BE SENT


      // INITIALIZE ALL VARS
      $Email=’’;
      $ch=’’;
      $Rec_Data=’’;
      $Temp_Output=’’;

      if($_SERVER[’REQUEST_METHOD’]===’POST’) { // REQUIRE POST OR DIE
      if(isset($_POST[’EmailAddress’])) $Email=$_POST[’EmailAddress’]; // GET EMAIL INTO VAR

      $feilds_email = $hook->getValue(’email’);
      $feilds_fname = $hook->getValue(’fullname’);
      $feilds_lname = $hook->getValue(’lastname’);
      $feilds_weddingdaye = $hook->getValue(’weddingday’);
      $email = $hook->getValue(’weddingmonth’);
      $email = $hook->getValue(’weddingyear’);

      $ch = curl_init(POSTURL);
      curl_setopt($ch, CURLOPT_POST ,1);
      curl_setopt($ch, CURLOPT_POSTFIELDS ,POSTVARS.$Email);
      curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
      curl_setopt($ch, CURLOPT_HEADER ,0); // DO NOT RETURN HTTP HEADERS
      curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL
      $Rec_Data = curl_exec($ch);

      ob_start();
      header("Content-Type: text/html");
      $Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
      $Temp_Output = ereg_replace (’ +’, ’ ’, trim($Temp_Output));
      $Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output);
      $Temp_Output = substr($Temp_Output,307,200);
      echo $Temp_Output;
      $Final_Out=ob_get_clean();
      echo $Final_Out;
      curl_close($ch);
      } else die(’Hacking attempt Logged!’);

      exit;
      /* tell our snippet we’re good and can continue */
      return true;
        • 36524
        • 8 Posts
        I am submitting an http post to Hubspot like this in my registration form. It is super important that the fields match the iContacts requirements on your form. I would ask iContact about a php/sql script to hook to your Icontact account/tracking.

        RegisteredUserHS is the name of the snippet


        Hope this helps:
        [[!Register?
            &postHooks=`RegisteredUserHS`  
            &submitVar=`registerbtn`
            &activationResourceId=`116`
            &activationEmailTpl=`lgnActivateEmailTpl`
            &activationEmailSubject=`Thank You for Registering!`
            &submittedResourceId=`117`
            &usergroups=`Customers`
            &store=`1`
            &validate=`nospam:blank,
                username:required,
                prefix:required,
                firstname:required:minLength=^3^,
                firstname:required:maxLength=^15^,
                lastname:required:minLength=^3^,
                lastname:required:maxLength=^15^,
                job_title:required,
                company:required,
          	password:required:minLength=^6^,
          	password_confirm:password_confirm=^password^,
                profession:required,
          	address:required,
              	city:required,
              	state:required,
              	zip:required,
              	country:required,
              	phone:required:maxLength=`15`,
                phone:required:minLength=`10`,
          	email:required:email`
            	&placeholderPrefix=`reg.`
        ]]
        • Hi Rachel, Did you ever get this sorted? (I know, it was long time ago!) But I am trying to do something similar with a posthook on the Login snippet that will simultaneously log a user in to another URL as well as the main MODX site. Wondering if what you learned might be of some help to me...
            Lucy Iannotti
            Following Sea design & development
            http://www.following-sea.com
            New Bedford, MA