Title: Detecting empty merge fields
Last modified: November 1, 2018

---

# Detecting empty merge fields

 *  Resolved [Ambyomoron](https://wordpress.org/support/users/josiah-s-carberry/)
 * (@josiah-s-carberry)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/detecting-empty-merge-fields/)
 * I come back to a function discussed earlier:
 *     ```
       add_filter( 'yikes-mailchimp-filter-before-submission', 'maybe_supply_FNAME_to_merge_field', 10, 1 );
   
       function maybe_supply_FNAME_to_merge_field( $merge_fields ) {
       	if ( empty( trim( $merge_fields['SALUTATION'] ) ) && ! empty( $merge_fields['FNAME'] ) ) {
       		$merge_fields['SALUTATION'] = $merge_fields['FNAME'];
       	}
       	return $merge_fields;
       }
       ```
   
 * It turns out that the expression
 * `empty( trim( $merge_fields['SALUTATION'] ) )`
 * always returns TRUE, whether the subscriber has entered a value in the SALUTATION
   field of the form or not.
 * I have confirmed that the merge field SALUTATION is correctly set in the Yikes
   form
 * I have also tried the expression:
    `!isset( $merge_fields['SALUTATION'] )` with
   the same result.
 * So how to fix that?

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

 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/detecting-empty-merge-fields/#post-10837822)
 * Hi Josiah,
 * The only way that `empty( trim( $merge_fields['SALUTATION'] ) )` would return`
   true` in every instance is if `$merge_fields['SALUTATION']` doesn’t exist. Can
   you show me your form so I can see which field `SALUTATION` is? It might be keyed
   off the MERGE tag (i.e. `MMERGE4` instead of the re-named key `SALUTATION`).
 *  Thread Starter [Ambyomoron](https://wordpress.org/support/users/josiah-s-carberry/)
 * (@josiah-s-carberry)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/detecting-empty-merge-fields/#post-10837944)
 * OK. Thanks for the hint. It turned out there was an error in my form. When I 
   fixed it, the function worked correctly.
 *  Plugin Contributor [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * (@yikesitskevin)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/detecting-empty-merge-fields/#post-10837964)
 * Awesome 🙂

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

The topic ‘Detecting empty merge fields’ 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/)

## Tags

 * [empty](https://wordpress.org/support/topic-tag/empty/)
 * [isset](https://wordpress.org/support/topic-tag/isset/)

 * 3 replies
 * 2 participants
 * Last reply from: [yikesitskevin](https://wordpress.org/support/users/yikesitskevin/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/detecting-empty-merge-fields/#post-10837964)
 * Status: resolved