0

I would like to change the usual message sent by WordPress which says the following:

Someone requested that the password be reset for the following account: http://myexample.com/

I know that this comes from wp-login.php which has the following lines:

$message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n";
$message .= network_home_url( '/' ) . "\r\n\r\n";

Is there any way I can change $message .= network_home_url( '/' ) to http://myexample.com/member by adding something in functions.php perhaps?

Many thanks.

0

Let's check the Codex and follow the links to the source:

3029    function network_home_url( $path = '', $scheme = null ) {
3030            if ( ! is_multisite() )
3031                    return home_url($path, $scheme);
3032    
3033            $current_site = get_current_site();
3034            $orig_scheme = $scheme;
3035    
3036            if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
3037                    $scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
3038    
3039            if ( 'relative' == $scheme )
3040                    $url = $current_site->path;
3041            else
3042                    $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
3043    
3044            if ( $path && is_string( $path ) )
3045                    $url .= ltrim( $path, '/' );
3046    
3047            /**
3048             * Filter the network home URL.
3049             *
3050             * @since 3.0.0
3051             *
3052             * @param string      $url         The complete network home URL including scheme and path.
3053             * @param string      $path        Path relative to the network home URL. Blank string
3054             *                                 if no path is specified.
3055        https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/link-template.php#L3029     * @param string|null $orig_scheme Scheme to give the URL context. Accepts 'http', https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/link-template.php#L3029'https',
3056             *                                 'relative' or null.
3057             */
3058            return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
3059    }

We see that, yes, there is a filter called network_home_url that we can use to alter the link. A simple filter such as the following would do it, though I doubt you want something this simplified in practice:

function alter_net_link_wpse_206603($url, $path, $orig_scheme) {
  return 'http://myexample.com/member';
}
add_filter('network_home_url','alter_net_link_wpse_206603',10,3);
  • Thank you very much. I am just unsure as to what you mean by saying that you doubt I want something this simply in practice? Is is unsafe to use this for the password reset message? Or should I alter $message .= network_home_url( '/' ) . "\r\n\r\n"; in another way? – Mica Oct 26 '15 at 15:39
  • You are changing an important address without checking for context. That is a cause for concern. – s_ha_dum Oct 26 '15 at 15:54
  • In that case I'd rather not use it but is there any way I can change the message that is specified in wp-login.php as follows: $message = __('Someone requested that the password be reset for the following account:') . "\r\n\r\n"; $message .= network_home_url( '/' ) . "\r\n\r\n"; – Mica Oct 26 '15 at 16:02
  • I had to reword my question and post a new question. – Mica Oct 28 '15 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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