• Resolved pievedepitti

    (@pievedepitti)


    Hi, I have installed the plugin and modified a code a bit to add NAME field.
    add_action( ‘mctb_before_submit_button’, function() {
    echo ‘<input type=”text” name=”FNAME” placeholder=”il tuo Nome” />’;
    });

    add_filter( ‘mctb_data’, function( $vars ) {
    $vars[‘FNAME’] = ( isset( $_POST[‘FNAME’] ) ) ? sanitize_text_field( $_POST[‘FNAME’] ) : ”;
    return $vars;
    });

    It works but I now need to add a second Country field and cannot find a way to let the code working.
    Can you help me please?

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

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

    (@lapzor)

    It should look something like this:

    add_action( ‘mctb_before_submit_button’, function() {
    echo ‘<input type=”text” name=”FNAME” placeholder=”il tuo Nome” />’;
    echo ‘<input type=”text” name=”COUNTRY” placeholder=”country” />’;
    });
    
    add_filter( ‘mctb_data’, function( $vars ) {
    $vars[‘FNAME’] = ( isset( $_POST[‘FNAME’] ) ) ? sanitize_text_field( $_POST[‘FNAME’] ) : ”;
    $vars[‘COUNTRY’] = ( isset( $_POST[‘COUNTRY’] ) ) ? sanitize_text_field( $_POST[‘COUNTRY’] ) : ”;
    return $vars;
    });

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

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi Lap,
    i tried already but modifying the code a bit according to mailchimp list settings

    add_action( ‘mctb_before_submit_button’, function() {
    echo ‘<input type=”text” name=”FNAME” placeholder=”il tuo Nome” />’;
    echo ‘<input type=”text” name=”MERGE3” placeholder=”Nazione” />’;
    });

    add_filter( ‘mctb_data’, function( $vars ) {
    $vars[‘FNAME’] = ( isset( $_POST[‘FNAME’] ) ) ? sanitize_text_field( $_POST[‘FNAME’] ) : ”;
    return $vars;
    $vars[‘MERGE3’] = ( isset( $_POST[‘MERGE3’] ) ) ? sanitize_text_field( $_POST[‘MERGE3’] ) : ”;
    return $vars;
    });

    Fatal error in line 3

    Plugin Contributor Harish Chouhan

    (@hchouhan)

    Hey @pievedepitti,

    Can you please share any more details about the error?

    Also, can you please let us know where you have placed this code?

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi
    I changed the snippet I wrote before.
    A Red Cross appears in the box when adding the third line and if I force it and save a fatal error page appears

    Plugin Contributor Lap

    (@lapzor)

    What is the full and exact error message you see? You my need to check your PHP error log to see it.
    Most likely a typo in the custom code.

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi solved.
    It was a matter of ‘ and ”

    for some reason cannot coy the code but have to re-write it because characters were not recognised
    thanks for your help

    Thread Starter pievedepitti

    (@pievedepitti)

    Hi. after an updating, the mailchimp topbar I customized using a snippet for both ITA and ENG languages is not showing properly and both language version are visible on the same page.
    cannot find a way to solve this issue

    Plugin Contributor Lap

    (@lapzor)

    So the code you’ve written to detect the language isn’t working anymore it seems…?
    Did you also update the multi language plugin?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘add name and country’ is closed to new replies.