Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for multisite lost password link for dudestack sites #70

Open
lukanja opened this issue Oct 4, 2023 · 0 comments
Open

Fix for multisite lost password link for dudestack sites #70

lukanja opened this issue Oct 4, 2023 · 0 comments

Comments

@lukanja
Copy link
Member

lukanja commented Oct 4, 2023

Currently on multisites, if an user wants to request a new password from domains other than the main site, the url gets formatted weirdly leading to 404-error.

Can be fixed using the lostpassword_url hook:

add_filter( 'lostpassword_url', __NAMESPACE__ . '\lost_password_url', 10, 2 );

An example of the function to pass (for development and production sites):

function lost_password_url( $lostpassword_url, $redirect ) {
  // On main site no need to do anything

  if ( get_main_site_id() === get_current_blog_id() ) {
    return $lostpassword_url;
  }

  if ( 'development' === getenv( 'WP_ENV' ) ) {
    $lostpassword_url = get_home_url() . '/wp-login.php?action=lostpassword';
    return $lostpassword_url;
  } else {
    $lostpassword_url = get_home_url() . '/wp/wp-login.php?action=lostpassword';
    return $lostpassword_url;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant