The question I asked here needs to be modified as I have a different problem. I asked the following question on the WordPress support forum but it seems that nobody has an answer to that. I wonder why? Here it is: I am trying to customize the password retrieval message by applying a filter as follows:

function retrieve_password_message_filter($message, $key, $user_login, $user_data) {

$message = __('Someone has asked to reset the password for the following username on this site:') . "\r\n\r\n";
    $message .= site_url( '/secrets/') . "\r\n\r\n";
    $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
    $message .= __('If this was a mistake, just ignore this email and nothing will happen.') . "\r\n\r\n";
    $message .= __('To reset your password, visit the following address:') . "\r\n\r\n";
    $message .= '<' . network_site_url("wp-login.php?action=rp&key=$key&login=" . rawurlencode($user_login), 'login') . ">\r\n";
    return $message;
add_filter ( 'retrieve_password_message', 'retrieve_password_message_filter');

This works up to a point but the link for the password reset is invalid - WordPress is applying only parts of the filter ignoring the username and password reset link. Obviously something else needs to be added to the code above but my searches everywhere seem to show that the code I am using is supposed to work. Does this mean that I have to copy the whole section from wp-login.php relevant to the password retrieval in order just to change the wording of the message? Would you be able to help?

1 Answer 1


You aren't requesting all of the parameters that your callback needs.This:

add_filter ( 'retrieve_password_message', 'retrieve_password_message_filter');

Should be:

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

Though you only need the first three, it looks loke.

  • This worked. I used only three parameters as you suggested. In my searching it appeared that parameters were not necessary for filters - it seems that this information is wrong. I wanted to mark the answer as useful but I am not allowed to yet.
    – Mica
    Commented Oct 28, 2015 at 15:27
  • I don't know where you found someone saying that the parameter's argument (the last one) isn't necessary, but that is absolutely incorrect.
    – s_ha_dum
    Commented Oct 28, 2015 at 15:41
  • Most examples with add_filter are shown without parameters. Also, some documentation says that they are optional. The information provided can be very confusing for someone like me. I wish I could find good material somewhere I could really learn from.
    – Mica
    Commented Oct 28, 2015 at 16:01
  • You don't need the parameter for the first argument. They are optional in the sense that if you don't need them you don't have to use them. But if you do need them you have to ask for them.
    – s_ha_dum
    Commented Oct 28, 2015 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.