• Resolved lbbjon

    (@lbbjon)


    Hello,

    Does wp-members support html and css within the ‘Email’ notification sectio?. I tried adding a template just to test, but only displayed code.

    Is only RichText allowed?

    Many thanks,
    Jon.

    • This topic was modified 5 years, 10 months ago by lbbjon.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    The plugin sends whatever WP is set to send. That’s plain text by default (WP does not assume an HTML default email). You can change that a number of ways:

    • Change all wp_mail() messages to HTML format with wp_mail_content_type.
    • Change all wp_mail() messages to HTML format by filtering the content type in the header using the wp_mail filter.
    • Change only WP-Members’ messages going through wp_mail() by using the wpmem_email_headers filter to change the content type in the wp_mail() header (only fires when the message is generated by WP-Members).

    Some practical examples:
    https://rocketgeek.com/filter-hooks/sending-html-emails-from-the-wp-members-plugin/

    • This reply was modified 5 years, 10 months ago by Chad Butler.
    Thread Starter lbbjon

    (@lbbjon)

    Thanks for getting back to me Chad.

    I am not really familiar with php, but if I created a custom plugin and activate it, would this override the core code or replace it? – If I were to use the php filter that specifically targets the wp-members plugin:

    add_filter( 'wpmem_email_headers', 'my_wpmem_html_email' );
    function my_wpmem_html_email() {
        return "Content-Type: text/html";
    }

    Many thanks,
    Jon.

    Thread Starter lbbjon

    (@lbbjon)

    Also, are there any risks associated with adding this php filter via a custom plugin? I.e. would it affect other emailing/notification plugins or operations I have set up.

    Plugin Author Chad Butler

    (@cbutlerjr)

    I am not really familiar with php, but if I created a custom plugin and activate it, would this override the core code or replace it?

    WP is loaded with “hooks” which can be either “filters” or “actions”. This is what allows WordPress to be customized, and it is the premise upon which all plugins are built.

    A filter hook allows you to change a value. There’s a value that WP generates, and then the hook is there to allow you an opportunity to change that before it gets used.

    In this particular case, the ‘wpmem_email_headers’ filter hook allows you to change the email headers that are passed to wp_mail() when WP-Members generates an email. In the example code, it’s just changing the content type so that it is an html email.

    Also, are there any risks associated with adding this php filter via a custom plugin? I.e. would it affect other emailing/notification plugins or operations I have set up.

    As I mentioned in the original answer – ‘wpmem_email_headers’ only affects emails generated by WP-Members.

    Thread Starter lbbjon

    (@lbbjon)

    Thanks for the explanation.

    I have added a custom plugin which included the php filter specific to wp-members, following the guide on your site.

    I am glad to say this has worked and now all emails send in HTML, as well as appear correctly.

    Thanks for the hand!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘HTML emails’ is closed to new replies.