<?php | |
/** | |
* Plugin Name: Multisite: Passwort Reset on Local Blog | |
* Plugin URI: https://gist.github.com/eteubert/293e07a49f56f300ddbb | |
* Description: By default, WordPress Multisite uses the main blog for passwort resets. This plugin enables users to stay in their blog during the whole reset process. | |
* Version: 1.0.0 | |
* Author: Eric Teubert | |
* Author URI: http://ericteubert.de | |
* License: MIT | |
*/ | |
// fixes "Lost Password?" URLs on login page | |
add_filter("lostpassword_url", function ($url, $redirect) { | |
$args = array( 'action' => 'lostpassword' ); | |
if ( !empty($redirect) ) | |
$args['redirect_to'] = $redirect; | |
return add_query_arg( $args, site_url('wp-login.php') ); | |
}, 10, 2); | |
// fixes other password reset related urls | |
add_filter( 'network_site_url', function($url, $path, $scheme) { | |
if (stripos($url, "action=lostpassword") !== false) | |
return site_url('wp-login.php?action=lostpassword', $scheme); | |
if (stripos($url, "action=resetpass") !== false) | |
return site_url('wp-login.php?action=resetpass', $scheme); | |
return $url; | |
}, 10, 3 ); | |
// fixes URLs in email that goes out. | |
add_filter("retrieve_password_message", function ($message, $key) { | |
return str_replace(get_site_url(1), get_site_url(), $message); | |
}, 10, 2); | |
// fixes email title | |
add_filter("retrieve_password_title", function($title) { | |
return "[" . wp_specialchars_decode(get_option('blogname'), ENT_QUOTES) . "] Password Reset"; | |
}); |
This comment has been minimized.
This comment has been minimized.
This is great. Solves so many hassles and works right out of the box. Thanks! |
This comment has been minimized.
This comment has been minimized.
Works great, as expected. I hope WordPress will fix it soon, so we won't need these fixes anymore! Thank you @eteubert! |
This comment has been minimized.
This comment has been minimized.
Can't believe wpmu doesn't support this already. Thanks a ton! |
This comment has been minimized.
This comment has been minimized.
Thanks a lot! Work out of the box. |
This comment has been minimized.
This comment has been minimized.
Here is a new error that I am getting:
|
This comment has been minimized.
This comment has been minimized.
You saved my day buddy. Working just perfect. Thanks :) |
This comment has been minimized.
This comment has been minimized.
Awesome! It still shows the Network Title in the email subject, like this: "[My Network Title] Password Reset". Do you know how to change it so it uses my site's title, and not the network's? |
This comment has been minimized.
This comment has been minimized.
Works great - thank you!! |
This comment has been minimized.
This comment has been minimized.
Hi, thanks for this! For those who install WordPress in a separate folder (https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory), you should use: |
This comment has been minimized.
This comment has been minimized.
WP is throwing a parse error after trying to activate the plugin: "syntax error, unexpected T_FUNCTION on line 13". Using WP Multiuser 4.7.2. UPDATE Mar 7, 2017 - Bug solved Added this line to my htaccess file:
|
This comment has been minimized.
This comment has been minimized.
Works like a charm, thanks! WP multisite 4.8.1 |
This comment has been minimized.
This comment has been minimized.
You should replace the hard coded site id on line 37
in case the main site is not id 1 |
This comment has been minimized.
This comment has been minimized.
This works great on the "lost password" link underneath the log in details, however, if they type in an incorrect password... the error box shows with the link saying... forgotten your password... click "lost your password" to change it. This link (that appears in the error box) is still taking them back to the main site and not the sub-site that was intended... any thoughts? |
This comment has been minimized.
This comment has been minimized.
It works without this plugin but having redirect to main site, it means reset password function works fine without using this plugin but to solve url redirection to related subdomain I'd like to use this plugins so after activating the plugin, I'm getting the following error: PHP 7.0.25 Any idea how to fix this? |
This comment has been minimized.
This comment has been minimized.
Hello. Great plugin, but I can confirm mehranhzh's issue. As of the current WP version 4.9.6, something seems to have changed in how Wordpress works that breaks its "drop in and go" functionality. Mail is correctly setup sending email with no problem until I activate this plugin. I get the same error: The email could not be sent. Does this error reference the PHP mail() function? wp_mail() function? Or is it talking about linux mail command? Thanks! |
This comment has been minimized.
This comment has been minimized.
on my multisite installation this plugin doesn't work. I try it in different ways..per functions.php as a plugin and as mu-plugin. but no luck |
This comment has been minimized.
This comment has been minimized.
Works great for me on WordPress 5.x Just added to sunrise.php in /wp-content/, with the mod from https://gist.github.com/eteubert/293e07a49f56f300ddbb#gistcomment-2213197 (see above) |
This comment has been minimized.
This comment has been minimized.
I unzipped then copied folder into my wpmudev host account: pe1.wpmudev.host NOTE: I did rename the folder to: |
This comment has been minimized.
This comment has been minimized.
Why don't you publish to the official repository? |
This comment has been minimized.
This comment has been minimized.
@davidperezgar I unfortunately have no time to maintain yet another plugin |
This comment has been minimized.
This comment has been minimized.
Ok ;) |
This comment has been minimized.
This comment has been minimized.
Nice fix! |
This comment has been minimized.
This comment has been minimized.
Thanks! |
This comment has been minimized.
This comment has been minimized.
Awesome snippets. It works well except 2 things: with Buddypress, they force another email and the link in it redirects to the main site. If I deactivate Buddypress (buddy boss), it works again. Second, there is a Site Name mention in the email shared to the user that is in my case always the main site. Except for thee 2 points, it works like a charm. Kudos! |
This comment has been minimized.
This is brilliant! Thanks very much.