Skip to content

Fix for multisite lost password link for dudestack sites #70

@lukanja

Description

@lukanja

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;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions