Support » Plugin: Email Template Designer - WP HTML Mail » Limit these emails to only one kind?

  • Resolved shayno90

    (@shayno90)


    Hi,

    I did read your notes on excluding HTML designs being applied to Woo emails and what not; but is there a way to apply them to ONLY a certain type of email? Kinda like an opposite function of what you created? basically, I only want the HTML designs to be applied to emails sent from Uncanny Automator. Everything else is totally fine and I don’t want it to conflict with FluentCRM and Woo etc…

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author Hannes Etzelstorfer

    (@haet)

    Hey @shayno90
    Yes you can use the same filter. Is there anything all your Automator mails have in common? Maybe part of the content or part of the subject?

    Thread Starter shayno90

    (@shayno90)

    Hi Hannes!

    Hmm.. I guess I could find something they have in common… For example, the subject line will always include “Your edits are ready”. So, basically, I would just need your plugin to apply to only those with that subject line

    Thread Starter shayno90

    (@shayno90)

    Is that possible?

    Thread Starter shayno90

    (@shayno90)

    Hi,
    I just cannot get your filter to work in the way I had hoped 🙁 Are you able to help out? The goal is to apply the HTML emails only to those emails with a subject of “XYZ”. I am using FluentCRM as a marketing tool and therefore can’t keep adding in subject lines to the code to avoid the template being applied.

    Thanks so much!

    Plugin Author Hannes Etzelstorfer

    (@haet)

    Hello @shayno90
    Use this code snippet to only use the template for emails containing “XYZ” in subject:

    
    add_filter( 'haet_mail_use_template', function( $use_template, $mail ){
        return strpos( $mail['subject'], 'XYZ' ) !== false;
    }, 10, 2 );
    
    Thread Starter shayno90

    (@shayno90)

    Thank you so much Hannes! Works flawlessly!

    Thread Starter shayno90

    (@shayno90)

    Oh, sorry – just a quick one; If I needed to add more email subjects, is this the right way to do it?

    add_filter( 'haet_mail_use_template', function( $use_template, $mail ){
        return strpos( $mail['subject'], 'Your edits & video are ready!' ) !== false;
    	return strpos( $mail['subject'], 'Please upload your photos' ) !== false;
    }, 10, 2 );

    Thanks!

    Plugin Author Hannes Etzelstorfer

    (@haet)

    No please try like that:

    
    add_filter( 'haet_mail_use_template', function( $use_template, $mail ){
        return strpos( $mail['subject'], 'Your edits & video are ready!' ) !== false
    	|| strpos( $mail['subject'], 'Please upload your photos' ) !== false
    	|| strpos( $mail['subject'], 'another subject' ) !== false;
    }, 10, 2 );
    
    Thread Starter shayno90

    (@shayno90)

    I actually tested this way here and it works:

    add_filter( 'haet_mail_use_template', function( $use_template, $mail ){
        return strpos( $mail['subject'], 'Your edits & video are ready!', 'Please upload your photos', 'Your Mentoring Session', 'Password Reset', 'Password Changed', 'Email Changed', 'Some plugins', 'Login Details', 'New User Registration', 'Your Site is Experiencing a Technical Issue' ) !== false;
    }, 10, 2 );

    But is your way better?

    Plugin Author Hannes Etzelstorfer

    (@haet)

    I didn’t know strpos() can handle multiple search terms. I also can’t find anything in the function documentation.
    I’m honestly not sure why your code even works. 😉

    Thread Starter shayno90

    (@shayno90)

    I just tried your code and followed what you did but I keep getting an error 🙁

    Uncaught Error: Object of class WP_Error could not be converted to string in /home/customer/www/rootspresets.com/public_html/wp-content/plugins/sg-security/templates/error.php:111 Stack trace: #0 /home/customer/www/rootspresets.com/public_html/wp-content/plugins/sg-security/core/Helper/Helper.php(111): include() #1 /home/customer/www/rootspresets.com/public_html/wp-includes/functions.php(3661): SG_Security\Helper\Helper->custom_wp_die_callback(Object(WP_Error), '', Array) #2 /home/customer/www/rootspresets.com/public_html/wp-includes/class-wp-fatal-error-handler.php(233): wp_die(Object(WP_Error), '', Array) #3 /home/customer/www/rootspresets.com/public_html/wp-includes/class-wp-fatal-error-handler.php(152): WP_Fatal_Error_Handler->display_default_error_template(Array, Object(WP_Error)) #4 /home/customer/www/rootspresets.com/public_html/wp-includes/class-wp-fatal-error-handler.php(57): WP_Fatal_Error_Handler->display_error_template(Array, Object(WP_Error)) #5 [internal function]: WP_Fatal_Error_Handler->handle

    Thread Starter shayno90

    (@shayno90)

    This is the code I used:

    add_filter( 'haet_mail_use_template', function( $use_template, $mail ){
        return strpos( $mail['subject'], 'Your edits & video are ready!' ) !== false
    	|| strpos( $mail['subject'], 'Please upload your photos' ) !== false
    	|| strpos( $mail['subject'], 'Your Mentoring Session' ) !== false;
    	|| strpos( $mail['subject'], 'Password Reset' ) !== false;
    	|| strpos( $mail['subject'], 'Password Changed' ) !== false;
    	|| strpos( $mail['subject'], 'Email Changed' ) !== false;
    	|| strpos( $mail['subject'], 'Some plugins' ) !== false;
    	|| strpos( $mail['subject'], 'Login Details' ) !== false;
    	|| strpos( $mail['subject'], 'New User Registration' ) !== false;
    	|| strpos( $mail['subject'], 'Your Site is Experiencing a Technical Issue' ) !== false;
    }, 10, 2 );
    Plugin Author Hannes Etzelstorfer

    (@haet)

    Only the last of the strpos() lines should end with a semicolon “;”

    Thread Starter shayno90

    (@shayno90)

    Oh of course. Thank you so much! Will run some more tests!

    Thread Starter shayno90

    (@shayno90)

    Works an absolute charm! Thank you so much Hannes!

Viewing 15 replies - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.