public
Last active

Stealth Login Page code snippet to add URL filter to logout/password reset. This will need to be added each time the plugin updates - add to plugin.php.

  • Download Gist
partial-plugin.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
// After all network activate/deactivate sections, before Global Variables
 
/**
* Edit the logout/login/lost_password URLs to the new custom URL
*
* @since 2.1.0
* @param $old
* @param $new
* @param $url
* @return array
*/
add_filter('site_url', 'wplogin_filter', 10, 3);
function wplogin_filter( $url, $path, $orig_scheme ) {
global $custom_url_ending;
 
$old = array( "/(wp-login\.php)/");
$new = array( $custom_url_ending );
 
return preg_replace( $old, $new, $url, 1);
}
 
// Additional Global Variables that have since been removed but are needed for the filter - I don't belive the last two are used because of nonce URLs.
 
$custom_url_ending = "wp-login.php?" . $slp_options['question'] . '=' . $slp_options['answer'];
$custom_logged_out = $custom_url . '?loggedout=true';
$custom_lost_password = $custom_url . '&action=lostpassword';

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.