Steps to reproduce (requires CCK and Content Profile modules):
1. Create a custom content type
- In the content type settings, check the "Use this content type as a content profile for users" box in the "Content Profile" section
- Add a custom field called first_name
- In the "Content profile" sub-tab, check the "Use on Registration" box
2. In Constant Contact module settings, go to "Change Settings" tab. Under "Extra Field Mappings", enter "FirstName:field_first_name"
3. Log out and register as a new user. Enter a value for the First Name field.
4. Log into Constant Contact and find the newly-created contact. Instead of having the correct value for the First Name field, the value appears as the string 'Array'.

Problem:
See lines 500-501 of constant_contact_user() in constant_contact.module. The POST value assigned to the extra field mapping is not a string in this case, rather it is an array. To get the correct string in this case, you would need to get the CCK field value as $_POST['field_first_name'][0]['value'].

Comments

justphp’s picture

Status: Active » Closed (won't fix)

The module was never meant to work with CCK fields.
Please follow the instructions provided in the module if you want to use extra fields.

thebuckst0p’s picture

StatusFileSize
new1.58 KB

This is very easily handled, see attached patch.

(Patch replaces tabs with spaces in the relevant snippet, and if:endif; with standard curly braces, per Drupal coding standards.)

Please review and commit, thank you!

thebuckst0p’s picture

Status: Closed (won't fix) » Needs review
justphp’s picture

Assigned: Unassigned » justphp
Status: Needs review » Closed (fixed)
nathaniel’s picture

Status: Closed (fixed) » Needs review

This wasn't implemented correctly.

<?php
		// parse custom fields
		$extra_fields = array();
		if(is_array($fields)):
		foreach($fields as $field):
			$fieldname = str_replace(' ','', $field);
			if(isset($field_mappings[$fieldname]) && isset($_POST[$field_mappings[$fieldname]])):

                // CCK fields / multi-value fields - strip down array to first value.
                // structure is probably $field[$delta][$value], but try to work for any array
                if (is_array($extra_fields[$fieldname])) {
                  while (is_array($extra_fields[$fieldname])) {
                    $extra_fields[$fieldname] = array_shift($extra_fields[$fieldname]);
                  }
                }
                else
                {
                    $extra_fields[$fieldname] = $_POST[$field_mappings[$fieldname]];
                }
			endif;
?>

$extra_fields[$fieldname] = $_POST[$field_mappings[$fieldname]]; needs to be above the CCK array check.

<?php
		// parse custom fields
		$extra_fields = array();
		if(is_array($fields)):
		foreach($fields as $field):
			$fieldname = str_replace(' ','', $field);
			if(isset($field_mappings[$fieldname]) && isset($_POST[$field_mappings[$fieldname]])):

                $extra_fields[$fieldname] = $_POST[$field_mappings[$fieldname]];
                // CCK fields / multi-value fields - strip down array to first value.
                // structure is probably $field[$delta][$value], but try to work for any array
                if (is_array($extra_fields[$fieldname])) {
                  while (is_array($extra_fields[$fieldname])) {
                    $extra_fields[$fieldname] = array_shift($extra_fields[$fieldname]);
                  }
                }
			endif;
?>
nathaniel’s picture

Version: 6.x-2.1 » 6.x-3.2
justphp’s picture

Status: Needs review » Closed (fixed)