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.
Put 4 at the end of the line instead of 2.
You must telladd_filter()andadd_action()how many arguments the hook function requires.