Support » Plugin: Easy Forms for Mailchimp » Invalid resource only for Contact 7 integration

  • Resolved Ambyomoron


    I am using the plugin ver. 6.8.5 for:
    1) optin to mailing list via the plugin’s own optin form
    2) optin from WooCommerce checkout form
    3) optin from Contact Form 7 ver. 5.5.3 forms

    1) and 2) work fine. 3) fails. The debug log shows “Invalid resource” as the message. I have the shortcode [yikes_mailchimp_checkbox] in the form, which is not checked by default. Clearing the API cache has no impact. Changing the target Mailchimp list has no effect. API key is double-checked.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @josiah-s-carberry,

    For reference, here is our knowledge base article on Contact Form 7 integration:

    Could you provide a link to a page using the CF7 form?


    Thread Starter Ambyomoron


    Thread Starter Ambyomoron


    Here is an update on the problem.
    I have defined a field in the Mailchimp signup form called “Country”. It is a drop-down list of various country names. I have defined a Contact 7 Form with exactly the same drop-down list of countries, which is mandatory. Here is the Contact 7 form code:

    *Country: [select* COUNTRY "Afghanistan" "Albania" "Algeria" "American Samoa" "Andorra" "Angola" "Antigua and Barbuda" "Argentina" "Armenia" "Aruba" "Australia" "Austria" "Azerbaijan" "Bahamas" "Bahrain" "Bangladesh" "Barbados" "Belarus" "Belgium" "Belize" "Benin" "Bermuda" "Bhutan" "Bolivia" "Bosnia and Herzegovina" "Botswana" "Brazil" "Brunei Darussalam" "Bulgaria" "Burkina Faso" "Burundi" "Cambodia" "Cameroon" "Canada" "Cape Verde" "Cayman Islands" "Central African Republic" "Chad" "Chile" "China" "Colombia" "Comoros" "Congo" "Congo, the Democratic Republic of the" "Costa Rica" "Côte d'Ivoire" "Croatia" "Cuba" "Cyprus" "Czech Republic" "Denmark" "Djibouti" "Dominica" "Dominican Republic" "Ecuador" "Egypt" "El Salvador" "Equatorial Guinea" "Eritrea" "Estonia" "Ethiopia" "Fiji" "Finland" "France""Germany" "Gabon" "Gambia" "Georgia" "Ghana" "Greece" "Grenada" "Guam" "Guatemala" "Guinea" "Guinea-Bissau" "Guyana" "Haiti" "Honduras" "Hong Kong" "Hungary" "Iceland" "India" "Indonesia" "Iran, Islamic Republic of" "Iraq" "Ireland" "Israel" "Italy" "Jamaica" "Japan" "Jordan" "Kazakhstan" "Kenya" "Kiribati" "Korea, Democratic People's Republic of" "Korea, Republic of" "Kuwait" "Kyrgyzstan" "Lao People's Democratic Republic" "Latvia" "Lebanon" "Lesotho" "Liberia" "Libya" "Liechtenstein" "Lithuania" "Luxembourg" "Macedonia" "Madagascar" "Malawi" "Malaysia" "Maldives" "Mali" "Malta" "Marshall Islands" "Mauritania" "Mauritius" "Mexico" "Micronesia, Federated States of" "Moldova" "Monaco" "Mongolia" "Montenegro" "Morocco" "Mozambique" "Myanmar" "Namibia" "Nauru" "Nepal" "Netherlands" "New Zealand" "Nicaragua" "Niger" "Nigeria" "Norway" "Oman" "Pakistan" "Palau" "Palestine" "Panama" "Papua New Guinea" "Paraguay" "Peru" "Philippines" "Poland" "Portugal" "Puerto Rico" "Qatar" "Romania" "Russian Federation" "Rwanda" "Saint Kitts and Nevis" "Saint Lucia" "Saint Vincent and the Grenadines" "Samoa" "San Marino" "Sao Tome and Principe" "Saudi Arabia" "Senegal" "Serbia" "Seychelles" "Sierra Leone" "Singapore" "Slovakia" "Slovenia" "Solomon Islands" "Somalia" "South Africa" "South Somalia" "South Sudan" "Spain" "Sri Lanka" "Sudan" "Suriname" "Swaziland" "Sweden" "Switzerland" "Syrian Arab Republic" "Taiwan" "Tajikistan" "Tanzania" "Thailand" "Timor-Leste" "Togo" "Tonga" "Trinidad and Tobago" "Tunisia" "Turkey" "Turkmenistan" "Tuvalu" "Uganda" "Ukraine" "United Arab Emirates" "United Kingdom" "United States" "Uruguay" "Uzbekistan" "Vanuatu" "Venezuela" "Viet Nam" "Virgin Islands, U.S." "Yemen" "Zambia" "Zimbabwe"]

    When a subscriber completes that form, the data being sent to the mailchimp API is not, however, the name of the selected country. Instead, the value ‘false’ is being sent. Mailchimp rejects the attempted signup, as ‘false’ is not a valid country name for the field merge_fields.COUNTRY.

    Finally, the reason the other uses of the plugin work OK is simply because I do not attempt to capture the country in those other cases.

    Thread Starter Ambyomoron


    I have solved the problem. Here is the cause, in case other php neophytes like me face a similar issue.

    In order to submit to Mailchimp values other than the email address, it is necessary to add a filter, as documented here:

    I had done this, but I did not realize that a Contact Form 7 form with a field of type SELECT, as in my COUNTRY list (see above), stores the user’s response in an array. Thus, the following code set the value of ‘COUNTRY’ in the merge variables array to 0, or FALSE:

    $merge_variables['COUNTRY'] = filter_var( $cf7_variables['COUNTRY'], FILTER_SANITIZE_STRING );

    Since there is only a single country selected, I need to take the first value in the array COUNTRY, like this:

    ‘$merge_variables[‘COUNTRY’] = filter_var( $cf7_variables[‘COUNTRY’][0], FILTER_SANITIZE_STRING );’

    When doing so, the value of COUNTRY in the merge variables array is now a proper country name. Mailchimp then accepts the subscription request.

    If the plugin’s debug log contained more useful information than simply ‘Invalid resource’, this issue would have been much easier to resolve.

    Plugin Contributor Tracy Levesque


    🏳️‍🌈 YIKES, Inc. Co-Owner

    Thanks, @josiah-s-carberry !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Invalid resource only for Contact 7 integration’ is closed to new replies.