diff --git a/wporg-two-factor.php b/wporg-two-factor.php index 73ba70a4..06ec0bce 100644 --- a/wporg-two-factor.php +++ b/wporg-two-factor.php @@ -11,7 +11,7 @@ namespace WordPressdotorg\Two_Factor; use Two_Factor_Core; -use WP_User; +use WP_User, WP_Error; defined( 'WPINC' ) || die(); @@ -122,6 +122,8 @@ function user_requires_2fa( WP_User $user ) : bool { * * This isn't usually necessary, since WordPress will prevent Subscribers from visiting other Core screens, but * sometimes plugins add screens that are available to Subscribers (either intentionally or not). + * + * @param WP_User|WP_Error $user */ function redirect_to_2fa_settings( string $redirect_to, string $requested_redirect_to, $user ) : string { if ( is_wp_error( $user ) ) { @@ -132,11 +134,9 @@ 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 'https://' . $primary_site->domain . trailingslashit( $primary_site->path ) . 'wp-admin/profile.php'; + return get_edit_account_url(); + // todo need to tell user why they were redirected, so need to have something like render_enable_2fa_notice on the front end ui? + // still need to keep the wpadmin one too, though } /** @@ -145,8 +145,6 @@ function redirect_to_2fa_settings( string $redirect_to, string $requested_redire * @codeCoverageIgnore */ function render_enable_2fa_notice() : void { - // @todo change this to use front-end URL/styles when 2FA settings are moved there. - ?>