Forum Replies Created

Viewing 15 replies - 1 through 15 (of 47 total)
  • Thread Starter mtlsam

    (@mtlsam)

    When using that exact text, it shows to the default translation you have for that text, but I’m not seeing how to replace this text with my own sentence for both languages. Where would I do that, that doesn’t result in the initial problem? Thanks.

    For example, even if I apply a string translation in WPML to the default “Sign me up for the newsletter!”, it doesn’t apply. It only applies the default translation that comes with the plugin (I suppose).

    So custom english text with the string translated results in the custom english text being show for all languages, and default english text with string translated results in default text showing everywhere, translated but not what I wrote.

    If the site used what I put as my label in my button, I could just handle translation that way, but “subscribe” doesn’t get used, it only uses what’s in the CF7 integration settings field. I have to put a text label here or else the button will show my list ID as the label.

    [mc4wp_checkbox “Subscribe” value=”123abc”]

    • This reply was modified 1 year, 4 months ago by mtlsam.
    • This reply was modified 1 year, 4 months ago by mtlsam.
    Thread Starter mtlsam

    (@mtlsam)

    Unfortunately no, I was already on 4.10.0 and 1.0.3 for the MC4WP: WPML compatibility plugin.

    Thread Starter mtlsam

    (@mtlsam)

    No problem! Anyone using this should use the following code and not the code in my other reply, as it wasn’t PHP 8 friendly.

    class WPCF7_SelectedCitiesHandler {
    public function __construct() {
    // Hook into Contact Form 7 mail sent action
    add_action('wpcf7_mail_sent', [$this, 'handle_mail_sent']);

    // Hook into MailChimp filter
    add_filter('mc4wp_subscriber_data', [$this, 'filter_subscriber_data'], 10, 1);
    }

    public function handle_mail_sent($contact_form) {
    // Add your handling logic here if needed, or leave it empty for now
    error_log('Mail sent action triggered. Form ID: ' . $contact_form->id());
    }

    public function filter_subscriber_data(MC4WP_MailChimp_Subscriber $subscriber) {
    // Add website subscriber tag
    $subscriber->tags[] = 'Website Newsletter Subscriber';

    // Retrieve the selected cities from the form submission directly
    $submission = WPCF7_Submission::get_instance();
    $posted_data = $submission->get_posted_data();
    $selected_cities = !empty($posted_data['cities']) ? $posted_data['cities'] : [];

    // Log the selected cities to ensure they are available
    error_log("Selected Cities in filter_subscriber_data (From Form Submission): " . print_r($selected_cities, true));

    // Check if selected cities exist and add them as tags dynamically
    if (!empty($selected_cities)) {
    foreach ($selected_cities as $city) {
    // Add city name as a tag
    $subscriber->tags[] = $city;
    }
    }

    // Log the updated tags to confirm
    error_log("Updated Tags: " . implode(", ", $subscriber->tags));

    return $subscriber;
    }
    }

    // Instantiate the handler
    new WPCF7_SelectedCitiesHandler();
    Thread Starter mtlsam

    (@mtlsam)

    This function I’ve produced appears to work for this purpose, it’s adding each of my selected array values in my cities checkbox as their own mailchimp tags!

    class WPCF7_SelectedCitiesHandler {

        public function __construct() {

            // Hook into Contact Form 7 mail sent action

            add_action('wpcf7_mail_sent', [$this, 'handle_mail_sent']);

            // Hook into MailChimp filter

            add_filter('mc4wp_subscriber_data', [$this, 'filter_subscriber_data'], 10, 1);

        }

        public function filter_subscriber_data(MC4WP_MailChimp_Subscriber $subscriber) {

            // Retrieve the selected cities from the form submission directly

            $submission = WPCF7_Submission::get_instance();

            $posted_data = $submission->get_posted_data();

            $selected_cities = !empty($posted_data['cities']) ? $posted_data['cities'] : [];

            // Check if selected cities exist and add them as tags dynamically

            if (!empty($selected_cities)) {

                foreach ($selected_cities as $city) {

                    // Add city name as a tag

                    $subscriber->tags[] = $city;

                }

            }

            return $subscriber;

        }

    }

    // Instantiate the handler

    new WPCF7_SelectedCitiesHandler();
    • This reply was modified 1 year, 4 months ago by mtlsam.
    Thread Starter mtlsam

    (@mtlsam)

    Thanks for your reply, I think there was a pasting issue with your example code that you wanted to share with me, it’s just a link to this post haha.

    Could you reshare the code you intended? Much appreciated!

    Thread Starter mtlsam

    (@mtlsam)

    Appreciate it thanks

    Thread Starter mtlsam

    (@mtlsam)

    Thanks!

    Thread Starter mtlsam

    (@mtlsam)

    Actually the problem is my lack of familiarity with html/css limitations within email apps like outlook, I don’t think this has anything to do with CF7 or WP at this point.

    Thread Starter mtlsam

    (@mtlsam)

    Turns out it was actually a conflict with Yoast, specifically the “force rewrite titles” option when it’s enabled.

    My theme was lacking a hook for Yoast, this force rewrite feature only appears in the settings if you’re missing that hook.

    I added the Yoast hook which allowed me to disable that setting, allowing your plugin to work.

    Thanks for getting the plugin back online!

    I get this too, on a site I just launched today on a fresh Siteground install, PHP 7.4.30.

    It doesn’t break my site but I see this error at the top of the page in the back end.

    Thread Starter mtlsam

    (@mtlsam)

    Thanks! I’ll await your investigation.

    Thread Starter mtlsam

    (@mtlsam)

    Following up on this for support please. I’m not sure why the code pasted in an ugly manner the first time, so here is a second attempt, it’s the exact same code.

    <?php if ( ICL_LANGUAGE_CODE==’en’ ) : ?>
    <?php echo do_shortcode(‘[ajax_load_more container_type=”ul” post_type=”post” custom_args=”lang:en” category=”teen-health” posts_per_page=”4″ repeater=”template_1″ scroll=”true” scroll_distance=”160″ transition=”fade” orderby=”date” order=”DSC”]’); ?>
    <?php elseif ( ICL_LANGUAGE_CODE==’fr’ ) : ?>
    <?php echo do_shortcode(‘[ajax_load_more container_type=”ul” post_type=”post” custom_args=”lang:fr” category=”sante-des-ados” posts_per_page=”4″ repeater=”template_1″ scroll=”true” scroll_distance=”160″ transition=”fade” orderby=”date” order=”DSC”]’); ?>
    <?php endif; ?>
    Thread Starter mtlsam

    (@mtlsam)

    It is 100% the same code, I have double checked that I am not loading the wrong form onto this page.

    Thread Starter mtlsam

    (@mtlsam)

    Well in CF7, this is my form, you can see the MC4WP- in each field.

    Should this be displaying in the DOM? I have another project using this same setup and it does not have any issues, on that project I also do not see any mention of MC4WP in the input fields in the DOM.

    <figure class="wpcf7_field_first_name">
      [text* first-name MC4WP-FNAME placeholder "First Name *"]
    </figure>
    
    <figure class="wpcf7_field_last_name">
      [text* last-name MC4WP-LNAME placeholder "Last Name *"]
    </figure>
    
    <figure class="wpcf7_field_email">
      [email* email MC4WP-EMAIL placeholder "Email *"]
    </figure>
    
    <figure class="wpcf7_field_phone">
      [tel phone MC4WP-TEL placeholder "Phone Number"]
    </figure>
    
    <figure class="wpcf7_field_company">
      [text* company MC4WP-COMP placeholder "Organization *"]
    </figure>
    
    <figure class="text-color-white">
      [mc4wp_checkbox]
    </figure>
    
    [cf7sr-simple-recaptcha]
    
    [submit "Get Access"]
    Thread Starter mtlsam

    (@mtlsam)

    Is there any way I can see the info being passed to Mailchimp via the browser developer tools? I really need to get this solved in order to launch a marketing campaign.

Viewing 15 replies - 1 through 15 (of 47 total)