• Resolved lifeofaminimalist

    (@thelifeofaminimalist)


    Hello,

    I added the below code to add the FNAME field to the top bar. How can I make this a mandatory field? Thank you in advance for all your help!!

    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;
    });

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hello,

    To make the top bar as a required field, please update the first few lines of code to the one below:

    add_action( ‘mctb_before_submit_button’, function() {
    echo ‘<input type="text" name="NAME" placeholder="Your name" required />’;
    });
    Thread Starter lifeofaminimalist

    (@thelifeofaminimalist)

    Thank you!!!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘top bar plugin FNAME mandatory field’ is closed to new replies.