Support » Plugin: MC4WP: Mailchimp for WordPress » Add name to top bar?

  • Resolved JackJJW

    (@jackjjw)


    Hiya,
    Is it possible to add the name field (first) to the top bar?
    As I understand it this is helpful for preventing spam, as you can then add it to the email campaigns to make newsletters more unique.
    It’s a great plugin.
    Thank you,
    Jack

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Lap

    (@lapzor)

    You can use the following code snippet to show a “NAME” field in your bar.

    add_action( 'mctb_before_submit_button', function() {
        echo '<input type="text" name="NAME" placeholder="Your name" />';
    });
    
    add_filter( 'mctb_subscriber_data', function( $subscriber ) {
        if( ! empty( $_POST['NAME'] ) ) {
            $subscriber->merge_fields['NAME'] = sanitize_text_field( $_POST['NAME'] );
        }
    
        return $subscriber;
    });

    Make sure to rename NAME to whatever the name fo the field is, such as FNAME for example.

    Hope that helps. If you have any questions, please let us know!

    Thank you @lapzor

    JackJJW

    (@jackjjw)

    HI @lapzor sorry for the very slow reply again – I was just wondering in which file I should add this code? Do I need to find the file for the bar itself?
    Thank you
    Jack

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    @jackjjw,

    You would need to add that code to the “functions.php” file located inside your active theme folder.

    @hchouhan I’ve done that and it is all up and running now. Thank you both! 🙂

    Plugin Contributor Lap

    (@lapzor)

    Awesome, ​Thanks for letting us know.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.