• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Plugins » WP-Members » Documentation » Filter and Action Hooks » wpmem_mc_merge

wpmem_mc_merge

Description

This filter hook allows you to change the MailChimp mail merge fields (if you are using any).  The default in the add-on are first name and last name from the default first and last name fields.  If you have changed those fields, or want to use different fields for other merge values, you can do it with this filter.

Usage

add_filter( 'wpmem_mc_merge', 'my_mc_merge_filter' );

function my_mc_merge_filter( $merge_vars ) {

	/*
	 * The default merge_vars, first and last name come in
	 * with the $merge_vars array.  If you are adding to
	 * the merge fields IN ADDITION TO those, you'll need
	 * to consider that as you filter the array.
	 *
	 * Here is an example where I keep the existing merge
	 * fields (first and last name) and add two additional
	 * fields to that array. Note how I obtain the values
	 * from the posted form data.
 	 */
	
	$my_new_field = array(
		'MC_MERGE_FIELD_1' => $_POST['wp-members-field-meta-key-1'],
		'MC_MERGE_FIELD_2' => $_POST['wp-members-field-meta-key-2'],
	);
	
	$my_new_merge = array_merge( $merge_vars, $my_new_field );
	
	return $my_new_merge;
}

Code Snippet Library [Subscriber Content]

  • Simple MailChimp merge field example
See a list of all filter and action hooks

Ready to get started?

Join Today!

© 2021 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Refund Policy