• Resolved Sebastian

    (@awesomegraphics)


    I want to disable the template for my newsletter. Therefore I want to check for the sender address and disable the template for all mails from this certain address.

    I try to follow the guide in your FAQ-section but I am not able to modify the example code for checking the sender address. Can you give me any hint on how to solve that?

    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Julian

    (@juliangk)

    Hello Sebastian,

    can you please paste the code you have been trying to use? If not please give me an example of the parameter, by which you would like to exclude the templates. Then I can give you a code example.

    Best regards
    Julian

    Thread Starter Sebastian

    (@awesomegraphics)

    Hi Julian,
    thanks for your quick answer!

    This is the code I tried (of course i changed ‘[email protected]’ to the sender address)

    add_filter( 'haet_mail_use_template', 'customize_template_usage', 10, 2 );
    function customize_template_usage( $use_template, $mail ){
    if( $mail['from'] == '[email protected]' )
    return false;
    return $use_template;
    }

    Plugin Support Julian

    (@juliangk)

    Hello Sebastian,

    at quick glance I would write the code like this:

    add_filter( 'haet_mail_use_template', 'customize_template_usage', 10, 2 );
    function customize_template_usage( $use_template, $mail ){
    	if( $mail['from'] == '[email protected]' ){
    		return false;
    	}
    	return true;
    }

    however, I have not checked my test-system to see if $mail['from'] is a valid parameter. You could do a var_dump($mail) or error_log(print_r($mail, true)); within this function to view which keys are available for use in the filter.

    Please let me know if you require further assistance. I will check the paremeters on my test system if you need further help.

    Best regards
    Julian

    Thread Starter Sebastian

    (@awesomegraphics)

    I tried both methods but don’t get any results shown nor can I find an error-logfile with the keys. Can you check it on your test system please? This would be super helpful!

    Plugin Support Julian

    (@juliangk)

    Hello Sebastian,

    depending on which plugins you are using your parameters could look differently. I have done an error_log of $mail on my test system using only WP HTML Mail and WP HTML Mail WooCommerce, this is what the array looks like:

    ### - $mail - ###
    Array (
        [to] => [email protected]
        [subject] => Deine Bestellung bei Dev 2 ist nun abgeschlossen
        [message] => <!DOCTYPE html>...
        [headers] => Content-Type: text/html
    	Reply-to: Dev 2 <[email protected]>
        [attachments] => Array
            (
            )
        [sender_plugin] => woocommerce
    )
    

    So here are the standard keys you can check and write a function for:

    [to]
    [subject]
    [message]
    [headers] 
    [attachments]
    [sender_plugin]

    This is all the help I can give you for now. You will have to write the function yourself, for your specific use case.

    Best regards
    Julian

    Thread Starter Sebastian

    (@awesomegraphics)

    Hi Julian,

    thanks for your help. It seems like deactivating for a certain sender address is not possible. However I was able to solve the problem using [sender_plugin]. Thanks again!

    Plugin Support Julian

    (@juliangk)

    Hello Sebastian,

    I am pleased it worked out!
    Please elt me know if there is anything else I can help with.

    Best regards
    Julian

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Disable for certain sender address’ is closed to new replies.