• Resolved pievedepitti

    (@pievedepitti)


    Hi,
    I have added two other fileds Name and Country in the top bar, but if I set them ad mandatory, then the top bar doesn’t collect data anymore because email shoud be the only required field.
    Any way to set all of the three as mandatory, so to be able to always collect name and country to create my targets?

    The page I need help with: [log in to see the link]

Viewing 10 replies - 16 through 25 (of 25 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    If the option for “Update Existing Subscribers” is enabled, then the message for “already subscribed” will not be displayed.

    After you updated the code, please test the form and then visit the “MC4WP > Others” page again and share any new errors you might see there.

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi, Harish
    noted your comment on the existing subscriber alert
    Error log is still the same from the last check. nothig done later on
    [2020-11-24 16:49:45] ERROR: Top Bar > Mailchimp API error: Bad Request. Invalid Resource. Your merge fields were invalid.
    – MMERGE6 : Please enter a value
    Request:
    PATCH https://us4.api.mailchimp.com/3.0/lists/761f82a349/members/c197cbba498fb4fa7e2f49e469344ce5
    {“status”:”pending”,”email_address”:”emil******@gm***.com”,”interests”:{},”merge_fields”:{},”email_type”:”html”,”tags”:[]}
    Response:
    400 Bad Request
    {“type”:”https://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/”,”title”:”Invalid Resource”,”status”:400,”detail”:”Your merge fields were invalid.”,”instance”:”6937041f-bc10-4de7-bd18-32fd8d1228b2″,”errors”:[{“field”:”MMERGE6″,”message”:”Please enter a value”}]}

    • This reply was modified 4 years, 4 months ago by pievedepitti.
    • This reply was modified 4 years, 4 months ago by pievedepitti.
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    I tested with my personal email “me@harish…com”. Can you please check if it’s logged in the error too as I received the “oops..” error message when I tested the form.

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi, sorry I was working on an other site where i have exactly the same issue.
    Same setting here now, but I just removed the required field for Name and Country form the Mailchimp audience settings that was probably the reason of the error you get

    [2020-11-24 19:22:35] ERROR: Top Bar > Mailchimp API error: Bad Request. Invalid Resource. Your merge fields were invalid.
    – MMERGE3 : Please enter a value
    Request:
    POST https://us13.api.mailchimp.com/3.0/lists/cbf4be4836/members
    {“status”:”pending”,”email_address”:”me@ha***********.com”,”interests”:{},”merge_fields”:{“FNAME”:”\u201d”},”email_type”:”html”,”tags”:[]}
    Response:
    400 Bad Request
    {“type”:”https://developer.mailchimp.com/documentation/mailchimp/guides/error-glossary/”,”title”:”Invalid Resource”,”status”:400,”detail”:”Your merge fields were invalid.”,”instance”:”e23f3bbd-887c-4c9a-b61e-92acb1846a43″,”errors”:[{“field”:”MMERGE3″,”message”:”Please enter a value”}]}

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    Do you want the fields to be mandatory? Also, do you get the same error even when you add details to these fields?

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi Harish,
    the fields are now mandatory using the code @lapzor suggested before.
    If I add Sara in the name field, Mailchimp collects it as a ” (double quote mark), if I add IT in the country field, Mailchimp doesn’t collect it at all

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    Let’s test one field at a time. Please remove the earlier code and use the one provided at https://github.com/ibericode/mc4wp-snippets/blob/master/add-ons/top-bar/add-name-field.php.

    Please make sure to update the field name and then test the form. If the name is sent to MailChimp.com then let us know and we can then work on the next field.

    Thread Starter pievedepitti

    (@pievedepitti)

    thats the code I use

    add_action( ‘mctb_before_submit_button’, function() {
    echo ‘<input type=”text” name=”NAME” placeholder=”Il tuo Nome” />’;
    });

    add_filter( ‘mctb_data’, function( $vars ) {
    $vars[‘FNAME’] = ( isset( $_POST[‘FNAME’] ) ) ? sanitize_text_field( $_POST[‘FNAME’] ) : ”;
    return $vars;
    });

    and doesn’t work. Name is not collected and substituted by “.
    That’s the log
    [2020-11-26 12:29:02] INFO: Top Bar > Successfully subscribed sole********@gm***.com

    Shall I try using a brand new text field in stead of using the standard Mailchimp one??

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi Harish.
    now it works. A new subscriber registered and the Name was properly saved by mailchimp. It doesn’t override a record if it is on the mailchimp audiece already….. but is a minor issue.
    This brand new one subscriber has been fully saved.
    now name is not a mandatory filed so “required” has to be added to the code.
    Wait for you for the next steps.

    • This reply was modified 4 years, 4 months ago by pievedepitti.
    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    I’m glad to hear that. Yes, please add the “Required” parameter to the code, and then please try adding the other field again and test it.

    Also when testing, please test from an incognito window that has no extensions installed.

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘how to add other mandatory fields than email’ is closed to new replies.