This is a tech note about advanced Gravity Forms add-on usage. Developer-level knowledge of WordPress is assumed.

I’m making a user sign-up flow with the Gravity Forms User Registration add on. It’s a great plugin, robust, well supported, with lots of great developer features. But I want to send an HTML email with a nice activate button in it, and that’s turned out not to be simple.

The email can be customized using the wpmu_signup_user_notification_email filter, that’s all fine. But it uses a text/plain content type in the email and this content type can’t be filtered within the wpmu_signup_user_notification() function that creates and sends the email.

But fortunately, you can filter this at wp_mail() function level with the wp_mail_content_type filter. You just need to create a condition for detecting when you are doing the submission of a Gravity Forms registration and tweak the output accordingly.

In my case, this would always be the Gravity Forms submission on a page called “Signup”. This is easy to detect from the current page name, and the existence of the gform_submit parameter in the $_REQUEST.

The full code that I used to tweak the content type is here.

/*
 * Use HTML content type for activation emails
 */
add_filter('wp_mail_content_type', 'filter_activation_email_type');
function filter_activation_email_type( $type ) {
  if (is_page('signup') && isset( $_REQUEST['gform_submit'] ) && $_REQUEST['gform_submit'] == '1') {
    return 'text/html';
  } else {
    return $type;
  }
}