Skip Navigation

[Résolu] CRED Email notification does not support HTML after applying custom filter

This support ticket is created Il y a 7 années et 3 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par marcB-6 Il y a 7 années et 3 mois.

Assisté par: Shane.

Auteur
Publications
#563540
Screenshot_10.png

I want to send custom email using function.php file..I have added filter to support HTML in email content as mentioned below.

function set_content_type() {
    return "text/html";
}

add_filter('wp_mail_content_type', 'set_content_type');

It works fine with my custom email but, Email which are sending by CRED i.e forgot password does not support HTML.

#563640

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi Marc,

Thank you for contacting our support forum.

Is the mail that you are trying to send generated from CRED ?

Please let me know.
Thanks,
Shane

#563780

Hi Shane,

The filter I have mentioned above is for my custom email which I am sending through function.php it is working fine for my custom email, but not for forgot password Email.

I have created page for forgot password and in that I have put shortcode to display it.

Please have a look at my code for custom email

add_action('edit_user_profile_update', 'send_user_details');

function send_user_details($user_id) {

    $all_meta_for_user = get_user_meta($user_id);
    if ($all_meta_for_user['wpcf-user-state'][0] == 1 && $_POST['wpcf']['user-state'] == 3) {
        $newpwd = random_password();
        wp_set_password($newpwd, $user_id);
        $userdata = get_userdata($user_id);
        $to = $userdata->data->user_email;
        $subject = "ICISA - Login Details";
        $content = "<p>Hi " . $userdata->data->user_login . "</p>";
        $content .= "<p>You are approved by admin.Please login using ".get_page_link(113)."</p>";
        $content .= "<p>Email : " . $userdata->data->user_email . "</p>";
        $content .= "<p>Password : " . $newpwd . "</p>";
        $content .= "<p>Thank You</p>";
        wp_mail($to, $subject, $content);
    }
}

/**
 * set_content_type [set content type text/html for email]
 * @param  {void}  [no input param]
 * @return {void}  [returns nothing]
 */
function set_content_type($content_type) {
    return "text/html";
}

add_filter('wp_mail_content_type', 'set_content_type');
#564317

Shane
Supporter

Les langues: Anglais (English )

Fuseau horaire: America/Jamaica (GMT-05:00)

Hi Marc,

Thanks for the more detailed information, but the forget password i believe is a default wordpress mail.

Could you try this plugin and let me know if it helps.
https://wordpress.org/plugins/custom-forgot-mail/

Thanks,
Shane

#564543

Hi Shane,

After doing research I fixed it my self.Instead of custom filter for content I have passed header parameter in wp_mail..Now, It works fine.

Thanks