Skip to content

Instantly share code, notes, and snippets.

@bdeleasa
Last active August 30, 2022 13:32
Show Gist options
  • Save bdeleasa/d3bff35069a9a025c82a to your computer and use it in GitHub Desktop.
Save bdeleasa/d3bff35069a9a025c82a to your computer and use it in GitHub Desktop.
Wordpress plugin that fixes an issue with WP Better Emails not being able to format Gravity Forms email notifications.
<?php
/**
* Plugin Name: Gravity Forms - WPBE Email Fix
* Plugin URI: https://gist.github.com/bdeleasa/d3bff35069a9a025c82a
* Description: Wordpress mu-plugin which fixes an issue with WP Better Emails not being able to format Gravity Forms email notifications.
* Version: 1.0.0
* Author: Brianna Deleasa
* Author URI: https://briannadeleasa.com
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: gravityforms-wpbe-fix
* Domain Path: /languages
*/
add_filter( 'gform_notification', 'gravityforms_wpbe_gform_notification', 10, 3);
/**
* Changes the Gravity Forms notification emails from HTML to plain text.
*
* @see https://docs.gravityforms.com/gform_notification/
*
* @param $notification array
* @param $form object
* @param $entry object
* @return array
*/
function gravityforms_wpbe_gform_notification( $notification, $form, $entry ) {
// is_plugin_active is not availble on front end
if( ! is_admin() )
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
// Check if WPBE is installed 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;
}
@Stoltze
Copy link

Stoltze commented Feb 2, 2017

Great function. Thanks a lot.

@bdeleasa
Copy link
Author

Glad it could help you! :)

@masoudimo
Copy link

It is a great help, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment