Skip to content

Commit

Permalink
redirect to primary url for multisite -fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
iandunn committed Nov 18, 2022
1 parent 09dbea8 commit 6ba651d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions wporg-two-factor.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

add_filter( 'two_factor_providers', __NAMESPACE__ . '\two_factor_providers', 99 ); // Must run _after_ all other plugins.
add_action( 'set_current_user', __NAMESPACE__ . '\remove_super_admins_until_2fa_enabled', 1 ); // Must run _before_ all other plugins.
add_action( 'login_redirect', __NAMESPACE__ . '\redirect_to_2fa_settings', 20, 3 ); // After `wporg_redirect_logins_to_front()`, before `WP_WPorg_SSO::redirect_to_policy_update()`.
add_action( 'login_redirect', __NAMESPACE__ . '\redirect_to_2fa_settings', 105, 3 ); // After `wporg_remember_where_user_came_from_redirect()`, before `WP_WPorg_SSO::redirect_to_policy_update()`.
add_action( 'user_has_cap', __NAMESPACE__ . '\remove_capabilities_until_2fa_enabled', 99, 4 ); // Must run _after_ all other plugins.

/**
Expand Down Expand Up @@ -124,8 +124,11 @@ function redirect_to_2fa_settings( string $redirect_to, string $requested_redire
return $redirect_to;
}

$primary_blog_id = (int) get_user_meta( $user->ID, 'primary_blog', true );
$primary_site = get_site( $primary_blog_id );

// todo Change this to match the front-end URL once that's implemented.
return admin_url( 'profile.php' );
return 'https://' . $primary_site->domain . trailingslashit( $primary_site->path ) . 'wp-admin/profile.php';
}

/**
Expand Down

0 comments on commit 6ba651d

Please sign in to comment.