We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9550
    • 123 Posts
    Would it be possible to use this method to bounce newly created users to a Campaign Monitor subscript list.

    Here’s Vitalized solution on how to do this with eForm:

    http://modxcms.com/forums/index.php/topic,36806.0.html
      • 9207 ☆ A M B ☆
      • 2,475 Posts
      Yes. You can use one of Campaign Monitor’s sample scripts as your starting point, then grab the necessary variables from the $_POST array and integrate them into Campaign Monitor’s code... save the result as a new Snippet. Then just have your WebLoginPE form post to a page containing your new Snippet.
        • 31654
        • 238 Posts
        Quote from: Everett at Jun 16, 2009, 11:20 PM

        Yes. You can use one of Campaign Monitor’s sample scripts as your starting point, then grab the necessary variables from the $_POST array and integrate them into Campaign Monitor’s code... save the result as a new Snippet. Then just have your WebLoginPE form post to a page containing your new Snippet.

        Sorry to sound like a total numb nut but can you show me how this can be done?

        Many thanks for any help
          Web Development, Web Hosting & Search Engine Marketing by:

          Vitalized | UK
          w. www.vitalized.co.uk

          Website Design | Search Engine Marketing (SEM) | UK MODx web hosting, secure, fast & 100% MODx compatible

          Vitalized | Australia
          w. www.vitalized-australia.com.au

          Website Design | Search Engine Marketing (SEM) | Australian MODx web hosting, secure, fast & 100% MODx compatible
          • 9207 ☆ A M B ☆
          • 2,475 Posts
          I’m cranking on another project right now, so I can’t lay this out for you explicitly, but essentially, you’ll have a form that posts to a page that a call to the Campaign Monitor API. Just make sure you include the CMBase.php in your call. Here’s an example of the CM call:

          <?php
          	//Sample using the CMBase.php wrapper to call Subscriber.AddWithCustomFields from any version of PHP
          	//Relative path to CMBase.php. 
          	require_once('PHPWrapperSamples-1-1.3/CMBase.php');
          		
          	$data['full_name'] = $_POST['full_name'];	
          	$data['email'] = $_POST['email'];
          	$data['dob_yyyy'] = $_POST['dob_yyyy'];
          	$data['dob_mm'] = $_POST['dob_mm'];
          	$data['zip'] = $_POST['zip'];
          	$data['city'] = $_POST['city'];
          	$data['state'] = $_POST['state'];
          	$data['gender'] = $_POST['gender'];
          		
          	//Your API Key. Go to http://www.campaignmonitor.com/api/required/ to see where to find this and other required keys
          	$api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
          	$client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
          	$campaign_id = null;
          	$list_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
          	$cm = new CampaignMonitor( $api_key, $client_id, $campaign_id, $list_id );
          	
          
          	send_one_to_cm($data, $cm);
          
          	//--------------------------------------------------------------------------
          	/*  You have to set up custom fields on the campaignmonitor site in order for
          	this to work.  The call should be formatted like this:
          	
          		$result = $cm->subscriberAddWithCustomFields
          			($email, $full_name, 
          			array(
          				'Genres' => array('comedy', 'mystery_suspense'), // Their API has trouble with &
          				'YearofBirth' => '1977',  // 4 digit Number
          				'MonthofBirth' => '04', // two digit Number
          				'Zip' => '90042',  // 5 digit Number
          				'City' => 'Los Angeles', // text
          				'State' => 'CA', // text abbrev.: CA, CO etc
          				'Gender' => 'Male', // Male | Female
          				)
          			);
          	
          	When CM gets a post like this, the record is pretty much wiped clean and the
          	new values replace any existing ones.  E.g. if a fan likes 2 genres and
          	wants to add a 3rd, you must send all 3. I.e. ANY info you include will 
          	override whatever's in the db for this user.
          
          	*/
          	function send_one_to_cm($data, $cm) {
          		
          		//This is the actual call to the method, passing email address, name and custom fields. Custom fields should be added as an array as shown here with the Interests and Dog fields.
          		//Multi-option field values are added as an array within this, as demonstrated for the Interests field.
          		//	$result = $cm->subscriberAddWithCustomFields('[email protected]', 'Joe Smith', array('Interests' => array('Xbox', 'Basketball'), 'Dog' => 'Fido'));
          
          
          		$result = $cm->subscriberAddWithCustomFields
          			($data['email'], $data['full_name'], 
          			array(
          				'YearofBirth' => $data['dob_yyyy'],
          				'MonthofBirth' => $data['dob_mm'],
          				'Zip' => $data['zip'],
          				'City' => $data['city'], // text
          				'State' => $data['state'], // text abbrev.: CA, CO etc
          				'Gender' => $data['gender'],
          				)
          			);
          
          		// Note: when you send this, ANY info you include will override whatever's in the db
          		// for this user.
          		
          		if($result['Code'] == 0) {
          			echo "Success : ".$data['email']."\n";
          		} else {
          			echo 'Error : ' . $result['Message'] . "\n----------------------\n";
          		
          			// Print out the debugging info
          			print_r($cm);
          			exit;
          		}
          	}
          
          ?>

            • 284
            • 5 Posts
            Can anybody out here please tell me how to create a registration form and how to execute the post process of the form huh
            I have read a lot of forums but unable to get it.....
              • 9207 ☆ A M B ☆
              • 2,475 Posts
              Did you look at the Wiki?

              This page has some examples and diagrams:
              http://wiki.modxcms.com/index.php/WebLoginPE_Examples
                • 284
                • 5 Posts
                Thanks Everett that link has helped me a lot....Seems like you have been working and modifying a lot in MODx.
                But now i have added an extra text field called "code" in the profile edit page and i want to save it to database. can you please tell me in which file should i make the changes.... and if possible can u tell me what are the changes to be made...
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  I’m glad that page has helped, Abhijit. You shouldn’t need to change any code. I think what you want to do can be done by editing the &customTable and &customFields parameters in your Snippet call.

                  The official docs are here:
                  http://svn.modxcms.com/crucible/browse/~raw,r=37/modx-components/webloginpe/trunk/assets/snippets/webloginpe/docs/parameters.html

                  I wrote some info about this on another Wiki page:
                  http://wiki.modxcms.com/index.php/WebLoginPE_HOWTOS
                    • 284
                    • 5 Posts
                    Again thanks for your help...but what i actually need to do is, show one text field only in profile edit page and not in register page and then save it’s value to database. then when user again comes to profile edit page he will not see the text field.... if he has entered the correct value in that text field in the previous attempt...
                    I did use the &customFields parameter to save the value of that text field to database...
                    Do you have any suggestions about how to achieve this...?
                      • 284
                      • 5 Posts
                      Hello Everett i have managed to save the value to the database but now the only problem left is that, i want to redirect the page back to other page only if there are no errors......

                      The reason behind redirecting is simply because the changes in profile edit part of the new text field which i added are not reflected even though they are saved to DB... may be because of ajax i guess..

                      How can i achieve this ? can you please explain it to me?

                      I tried using the following methods in the snippet where $type == ’simple’ and case == saveprofilesimple

                      i replaced return $displayProfileTpl; with return $displaySuccessTpl; but it displays the success message without redirecting.

                      then

                      i replaced return $displayProfileTpl; with $url = $modx->makeURL($profileHomeId); $modx->sendRedirect($url,0,’REDIRECT_REFRESH’);return;
                      but this gave me an error...