• Resolved mezzomedia

    (@mezzomedia)


    Hi MC4WP team,

    Previously, I had been able to prevent ad-blockers from hiding the MC4WP form by replacing the form class with a more generic name, as follows:

    /**
     * Replace MC4WP default form class to prevent ad-blocker from hiding the subscribe form.
     * See also https://kb.mc4wp.com/add-css-class-to-form-element/
     */
    function my_mc4wp_replace_form_class( $classes ) {
    	// Remove MC4WP default class
    	$remove_value = 'mc4wp-form';
    	if ( ( $key = array_search($remove_value, $classes) ) !== false ) {
    		unset( $classes[$key] );
    	}
    
    	// Add generic class name
    	$classes[] = 'form-latestnews';
    
    	return $classes;
    }
    add_filter( 'mc4wp_form_css_classes', 'my_mc4wp_replace_form_class' );

    Unfortunately, ad-blockers have smartened up and are now also recognizing MC4WP by the MC4WP form ID (e.g. mc4wp_form_widget-2 and mc4wp-form-1).

    I have found the ‘mc4wp_form_element_attributes’ filter, but this does not seem to allow changing of the form ID.

    How can one replace the MC4WP form ID to make it more generic, and thus prevent ad-blockers from hiding the form?

    • This topic was modified 2 years, 10 months ago by mezzomedia.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Lap

    (@lapzor)

    It’s currently not possible to change the form id, and it might even break the plugin in some cases if you do manage to change the id…

    Normally ad-blockers don’t block our forms, unless someone intentionally setup a more aggressive filter list that blocks email subscription forms as well as advertisements.

    If you have any questions, please let me know!

    Thread Starter mezzomedia

    (@mezzomedia)

    Ok, thanks for the quick reply, @lapzor !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ad blocker blocks form ID’ is closed to new replies.