Feature Request
After the submission of this issue I wanted to update with an potential path to incorporating this functionality into the module.
Add mapping of other fields on user registration form.
This would require modification of the field type /src/Plugin/Field/FieldType/ConstantContactListItem.php and adding additional field mapping settings (other than just the email address) and probably modification to _ik_constant_contact_entity_subscribe_on_save to set the other additional fields.
Original Issue
1. We have implemented a feature to subscribe new users to a Constant Contact list upon registration. To achieve this, we have made the following modifications:
2. Added a 'Signup List' field of type 'Constant Contact Lists' to the 'Create new account' form at /user/register.
Incorporated additional fields that correspond to Constant Contact's available fields:
- field_first_name
- field_last_name
- field_company_name
- field_job_title
- field_street
- field_city
- field_state
- field_postal_code
- field_country
However, we've encountered an issue: upon form submission, only the email address is being added to the new contact in Constant Contact.
We are seeking guidance on how to properly map the above fields from the registration form to their respective fields in Constant Contact.
We have observed that using the 'General Interest Signup Block' successfully adds the data to the new contact in Constant Contact. However, this method does not store the information under the User entity in our system.
We would greatly appreciate any advice on how to resolve this issue, ensuring that all relevant user data is both stored in our system and successfully transmitted to Constant Contact.
Thank you for your assistance in this matter.
Issue fork ik_constant_contact-3468149
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
rosemaryreilmanHello and thanks for reaching out. I will try to take a closer look as soon as I can.
A couple of suggestions on what you can look at in the meantime:
There are hooks that fire before sending user data to constant contact. This one could be helpful:
hook_ik_constant_contact_contact_data_alterdetails can be found inik_constant_contact.api.phpThat may be a little more complicated but could be useful.
The email address from an entity is mapped via field settings in
Drupal\ik_constant_contact\Plugin\Field\FieldType\ConstantContactListItemLikely this file may need to be modified to map the other user/entity fields.
I'll take a look as soon as I am able.
Thanks!
Comment #3
alexi721 commentedHi Rosemary:
I will look at both files and use them as guide on how to add additional fields.
Thank you very much for your quick reply, which I really appreciated.
Alex
Comment #4
alexi721 commentedHi Rosemary:
Using 'hook_ik_constant_contact_contact_data_alter' I am able to get the fields first_name, last_name, company_name, job_title, phone_number on CC populated.
However, none of the 'street_address' field get inserted. I verified the $data object has all the correct field names and values.
Could you please provide an example? Below is my code:
Thank you for your time and consideration.
Comment #5
rosemaryreilmanThe line should actually should be
I think that's the issue
Comment #6
alexi721 commentedHi Rosemary:
Removing the brackets fixed the issue and the 'street_address' fields get populated now on Constant Contact.
For developers who also prefer to utilize the Drupal's Register form and want the custom account fields added to the $data array (my field names are listed above in the text of the ticket), the following assignments were added below line #223: '$fieldMapping = $fieldDefinition->getSetting('field_mapping');' of v3.1.9 of this module:
The fields first_name, last_name, company_name, job_title and phone_number get inserted without extra code.
For the remaining fields I added the following code to the end of the 'ik_constant_contact.module' file:
Comment #7
rosemaryreilmanThat's great. I am going to keep this open for now as a feature request because I'd like to integrate this as an option with the User registration form.
Comment #8
rosemaryreilmanComment #10
rosemaryreilmanOk created a merge request with some changes to integrate the entity save and mapping of other CC fields. I have no added custom field support yet but thought this might be a good start. Feel free to give it a try.
Comment #12
rosemaryreilmanIssue has been inactive for 4 months. I'm going to merge the code into 4.x branch and create an alpha2 release.
Comment #13
rosemaryreilman