From 056be2233e2595cd182423a54822b0e7392c3600 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 4 Sep 2024 22:02:46 +1000 Subject: [PATCH] Allow get_edit_account_url() & get_onboarding_account_url() to output links for a specific user. --- wporg-two-factor.php | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/wporg-two-factor.php b/wporg-two-factor.php index ced286f5..bbe3ebd5 100644 --- a/wporg-two-factor.php +++ b/wporg-two-factor.php @@ -368,17 +368,35 @@ function block_webauthn_settings_page() { * Get the URL of the Edit Account screen. * * @codeCoverageIgnore + * + * @param int|WP_User $user Optional. The user to get the URL for. Default is the current user. + * @return string */ -function get_edit_account_url() : string { - return 'https://profiles.wordpress.org/' . ( wp_get_current_user()->user_nicename ?? 'me' ) . '/profile/edit/group/3'; +function get_edit_account_url( $user = false ) : string { + if ( ! $user ) { + $user = wp_get_current_user(); + } elseif ( is_numeric( $user ) ) { + $user = get_user_by( 'id', $user ); + } + + return 'https://profiles.wordpress.org/' . ( $user->user_nicename ?? 'me' ) . '/profile/edit/group/3/'; } /** * Get the URL of the onboarding screen. * * @codeCoverageIgnore + * + * @param int|WP_User $user Optional. The user to get the URL for. Default is the current user. + * @return string */ -function get_onboarding_account_url() : string { +function get_onboarding_account_url( $user = false ) : string { + if ( ! $user ) { + $user = wp_get_current_user(); + } elseif ( is_numeric( $user ) ) { + $user = get_user_by( 'id', $user ); + } + return 'https://profiles.wordpress.org/' . ( wp_get_current_user()->user_nicename ?? 'me' ) . '/profile/security'; }