Skip to content

Commit

Permalink
Allow get_edit_account_url() & get_onboarding_account_url() to output…
Browse files Browse the repository at this point in the history
… links for a specific user.
  • Loading branch information
dd32 committed Sep 4, 2024
1 parent 9b59fc7 commit 056be22
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions wporg-two-factor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down

0 comments on commit 056be22

Please sign in to comment.