Last active
August 30, 2022 13:32
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Glad it could help you! :)
It is a great help, thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great function. Thanks a lot.