Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Forked from ideadude/my_fix_wpelogin.php
Last active July 29, 2020 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dparker1005/5873c84aa07ebfaf415949c192d68e06 to your computer and use it in GitHub Desktop.
Save dparker1005/5873c84aa07ebfaf415949c192d68e06 to your computer and use it in GitHub Desktop.
Fix password reset behavior when using PMPro login page on WP Engine hosting.
<?php
// Copy from below here...
/*
* In addition to adding this code to your site, note that
* WP Engine also has aggressive caching that your login page
* should be excluded from, especially if you experience issues
* with your login page.
* https://wpengine.com/support/cache/#Cache_Exclusions
*/
/**
* Add wpe-login parameter when sending lost password email.
*/
function my_pmpro_fix_wpe_lostpass( $url ) {
$url = add_query_arg( 'wpe-login', true, $url );
return $url;
}
add_filter( 'lostpassword_url', 'my_pmpro_fix_wpe_lostpass' );
/**
* Add wpe-login parameter when resetting password.
*/
function my_pmpro_fix_wpe_resetpass( $url, $path ) {
if ( strpos( $path, 'action=resetpass' ) !== false && strpos( $path, 'wpe-login=true' ) === false ) {
$url = add_query_arg( 'wpe-login', 'true', $url );
}
return $url;
}
add_filter( 'site_url', 'my_pmpro_fix_wpe_resetpass', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment