By default, the Mailchimp Top Bar plugin will only show an email field as this will convince the most people to subscribe to your list, since it requires so little effort.
However, capturing an additional name field gets you the possibility to personalize your emails just a bit more. If you value personalized emails more than having a somewhat bigger list, here’s how to add a name field to your sign-up bar.
The following snippet needs to be added to your theme its functions.php file.
add_action( 'mctb_before_submit_button', function() {
echo '<input type="text" name="NAME" placeholder="Your name" />';
});
add_filter( 'mctb_data', function( $vars ) {
$vars['NAME'] = ( isset( $_POST['NAME'] ) ) ? sanitize_text_field( $_POST['NAME'] ) : '';
return $vars;
});
Please make sure to replace all occurrences of “NAME” in the snippet with the actual merge tag of the Mailchimp field you want to capture.
Extra: if you want to show the additional field just before the email field, please change mctb_before_submit_button
to mctb_before_email_field
in the above code snippet.