How to add WordPress password reset link in HTML email?
P粉136356287
P粉136356287 2023-09-02 13:52:43
0
1
537

I'm trying to replace the WP core password reset email with an Html email. Overall it works great, the emails are well formatted and sent correctly. However, implementing a dynamic reset of the link doesn't work (as does the username, but that's not even the most important thing)

I used the following code in my template's functions.php:

add_filter( 'wp_mail_content_type','prefix_set_content_type' ); function prefix_set_content_type() { return "text/html"; } add_filter( 'retrieve_password_message', 'replace_retrieve_password_message', 10, 2 ); function replace_retrieve_password_message( $message, $key, $user_login, $user_data ) { $message = 'A lot of html content (basically formatted emails)'

Doing so will result in a fatal error because the function expects 4 parameters but only receives 2 (said in the bug report email). When I omit $user_data and $key, the error disappears, but I still don't know how to implement dynamic linking...

When I try to include this link in Html, it only sends half of the link (probably due to the '""'):

' . network_site_url( "wp-login.php?action=rp&key=$key&login=" . rawurlencode( $user_login ), ' login' ) . '

Does anyone have any ideas on how to resolve this issue? Thanks.

P粉136356287
P粉136356287

reply all (1)
P粉838563523

Put 4 at the end of the line instead of 2.

add_filter('retrieve_password_message', 'replace_retrieve_password_message',10,4);

You must telladd_filter()andadd_action()how many arguments the hook function requires.

    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!