• Resolved ntel

    (@ntel)


    Hi,

    I have a blog that’s split into 100s of categories, say baseball, football, basketball, and 999 other sports for instance. There are too many categories to create as many groups in Mailchimp and use a different form for each group.

    So my workaround is to dynamicalla populate the sport field using PHP as I read here: https://yikesplugins.com/support/knowledge-base/filters/. I precreated the SPORT merge field on Mailchimp, and as a tryout I’m trying to pass the word “baseball” to the merge field.

    function populate_SPORT_field( $user_data ) {
    $user_data[‘SPORT’] = ‘baseball’;
    return $user_data;
    }
    add_filter( ‘yikes-mailchimp-before-submission’ , ‘populate_SPORT_field’ );

    Unfortunaly, the string does not get passed at all, and on my list, a new user is added, but the SPORT field remains empty. Any idea or pointer? Thank you so much!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @ntel,

    The code looks correct. Can you confirm that you’re using a text MERGE field and the MERGE tag is called SPORT?

    Thank you,
    Kevin.

    Edit: this is a duplicate of https://wordpress.org/support/topic/insert-tags-into-forms-for-mailchimp-tagging/#post-10740588.

    Thread Starter ntel

    (@ntel)

    Hi Kevin, thank you very much for the answer. Referencing to the other thread, I’ll allow myself to continue on this one, because this is where I am closer to something interesting that actually can apply.
    ***
    The following code:

    function populate_SPORT_field( $user_data ) {
    $user_data[‘SPORT’] = ‘baseball’;
    return $user_data;
    }
    add_filter( ‘yikes-mailchimp-before-submission’ , ‘populate_SPORT_field’ );

    Indeed doesn’t work in my functions.php, in spite of having precreated the field as a text field :/

    In my case, even the code you give in the filter page (which I tried as a test):

    function populate_FNAME_field( $user_data ) {
    	if( is_user_logged_in() ) {
    		if( isset( $user_data['FNAME'] ) ) {
    		get_currentuserinfo();
    		$user_data['FNAME'] = $current_user->user_firstname;
    		}
    	}
    return $user_data;
    }
    add_filter( 'yikes-mailchimp-before-submission' , 'populate_FNAME_field' );

    Unfortunately does not work either, in so far as it does not populate and/or update the filled first name of a user when s/he’s logged in.

    I’ve been banging my head for 36 hours now :/ – one potential avenue I was thinking was using the prefilled, dynamically-generated default value of a hidden form that I noticed from Easy Forms, specifically {page_url}, and then parse this URL in a predefined segment within Mailchimp to extract the sport name…

    The good news is that {page_url}, unlike string from the above function, gets transmitted to Mailchimp! The bad news is that in my case not all page have the “sport name” in the URL :/.

    I of course can give you my website’s name in a PM.

    Thanks a lot,
    Ntel

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @ntel,

    I’m not sure why the snippets aren’t working… Feel free to email us at plugins [at] yikesinc [dot] com. Being able to see your form might help me better understand the issue.

    Thank you,
    Kevin.

    Thread Starter ntel

    (@ntel)

    Just sent, thank you!
    Sophie

    Plugin Contributor Tracy Levesque

    (@liljimmi)

    🏳️‍🌈 YIKES, Inc. Co-Owner

    Hi I am going to close this, since the conversation has moved offline.

    Thank you,
    -Tracy

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Adding data before submission’ is closed to new replies.