WordPress.org

Ready to get started?Download WordPress

Forums

WP Better Emails
[resolved] not working with gravityforms (11 posts)

  1. davidsky
    Member
    Posted 1 year ago #

    Wp better emails is not working with notifications sent by gravityforms.

    Any solution ?

    Best Regards,
    D.

    http://wordpress.org/extend/plugins/wp-better-emails/

  2. hellonico
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  3. Damian
    Member
    Posted 1 year ago #

    Add in to your functions.php the following:

    add_filter('gform_notification_format','gf_email_format');
    function gf_email_format(){
    	return 'text/plain';
    }
  4. Damian
    Member
    Posted 1 year ago #

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

  5. hellonico
    Member
    Plugin Author

    Posted 1 year ago #

    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.

  6. Damian
    Member
    Posted 1 year ago #

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

    Thanks anyway

  7. whiteweazel21
    Member
    Posted 8 months ago #

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

    Thanks

  8. sfoxe
    Member
    Posted 4 months ago #

    @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.

  9. hellonico
    Member
    Plugin Author

    Posted 4 months ago #

    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;
    }
  10. sfoxe
    Member
    Posted 4 months ago #

    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;
    }
  11. hellonico
    Member
    Plugin Author

    Posted 4 months ago #

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

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.