Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Nicolas Lemoine

    (@nlemoine)

    Hi davidsky,

    This is because gravityforms already sends the emails as “text/html”. The emails must be “text/plain” to be wrapped by the HTML template.

    Add in to your functions.php the following:

    add_filter('gform_notification_format','gf_email_format');
    function gf_email_format(){
    	return 'text/plain';
    }

    nlemoine, maybe you can add that filter in the future to avoid problems. Thanks for the great plugin!

    Plugin Author Nicolas Lemoine

    (@nlemoine)

    Hi timersys,

    Unfortunately, I can’t add that kind of filter because the notfications of gravity forms may contain HTML that could mess with the email template. The probably should add an option whether to send text or HTML emails, like many plugins do.

    Fair enough. In my case it worked but my notifications don’t contain any Html

    Thanks anyway

    Does this still work? I added the function to my child theme’s php, but still getting default e-mails.

    Thanks

    @whiteweazel21 – I also find this is broken, even with the filter in place. I’ve tried setting the Gravity Forms email format to either “text” (as per their updated documentation) or “text/plain” (as per above), but no dice.

    Manually editing line #432 of wpbe.php to True gets it working properly, but the formatting of the content is now wrong. There are additional carriage returns and spacing around the content.

    I think this is the best plugin for this functionality, except Gravity Forms not working is a deal breaker. I’ll be using WP Email Template plugin in the meantime until this is resolved.

    Plugin Author Nicolas Lemoine

    (@nlemoine)

    Hi,

    Just digged into the gravity forms documentation and found this :
    http://www.gravityhelp.com/documentation/page/Gform_notification

    Look at example 4. I tested it and everything looks ok.

    Short answer for lazy people, paste this in your theme functions.php file :

    add_filter('gform_notification', 'change_notification_format', 10, 3);
    function change_notification_format( $notification, $form, $entry ) {
    
        // change notification format to text from the default html
        $notification['message_format'] = "text";
    
        return $notification;
    }

    Nice work. How about extending that a bit further so it only does it if WP Better Emails is activated, as well as forcing Disable AutoFormat so the output doesn’t have double linebreaks.

    add_filter('gform_notification', 'change_notification_format', 10, 3);
    function change_notification_format( $notification, $form, $entry ) {
    	if (class_exists('WP_Better_Emails')) {
    		// change notification format to text from the default html
        	$notification['message_format'] = "text";
    		// Disable auto formatting so you don't get double line breaks
    		$notification['disableAutoformat'] = true;
    	}
        return $notification;
    }
    Plugin Author Nicolas Lemoine

    (@nlemoine)

    Checking if the class exists is a little bit different from the plugin being active. You should use is_plugin_active.

    add_filter('gform_notification', 'change_notification_format', 10, 3);
    function change_notification_format( $notification, $form, $entry ) {
    
    	// is_plugin_active is not availble on front end
    	if( !is_admin() )
    		include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
    	// does WP Better Emails exists and activated ?
    	if( !is_plugin_active('wp-better-emails/wpbe.php') )
    		return $notification;
    
    	// change notification format to text from the default html
        $notification['message_format'] = "text";
    	// disable auto formatting so you don't get double line breaks
    	$notification['disableAutoformat'] = true;
    
        return $notification;
    }
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘not working with gravityforms’ is closed to new replies.