Title: Adding data before submission
Last modified: October 1, 2018

---

# Adding data before submission

 *  Resolved [ntel](https://wordpress.org/support/users/ntel/)
 * (@ntel)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/)
 * 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/](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](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10740513)
 * Hi [@ntel](https://wordpress.org/support/users/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](https://wordpress.org/support/topic/insert-tags-into-forms-for-mailchimp-tagging/#post-10740588).
    -  This reply was modified 7 years, 7 months ago by [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/).
    -  This reply was modified 7 years, 7 months ago by [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/).
 *  Thread Starter [ntel](https://wordpress.org/support/users/ntel/)
 * (@ntel)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10741932)
 * 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](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10742390)
 * Hi [@ntel](https://wordpress.org/support/users/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](https://wordpress.org/support/users/ntel/)
 * (@ntel)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10742835)
 * Just sent, thank you!
    Sophie
 *  Plugin Contributor [Tracy Levesque](https://wordpress.org/support/users/liljimmi/)
 * (@liljimmi)
 * 🏳️‍🌈 YIKES, Inc. Co-Owner
 * [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10743346)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/yikes-inc-easy-mailchimp-extender_a1c7e5.
   svg)
 * [Easy Forms for Mailchimp](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yikes-inc-easy-mailchimp-extender/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/)
 * [Active Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yikes-inc-easy-mailchimp-extender/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [Tracy Levesque](https://wordpress.org/support/users/liljimmi/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/adding-data-before-submission/#post-10743346)
 * Status: resolved