Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor wp_registration_url() to accept an optional redirect parameter #7725

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,17 +472,26 @@ function wp_login_url( $redirect = '', $force_reauth = false ) {
*
* @since 3.6.0
*
* @param string $redirect Optional path to redirect to on registration.
* @return string User registration URL.
*/
function wp_registration_url() {
function wp_registration_url( $redirect = '' ) {
// Set base registration URL.
$register_url = site_url( 'wp-login.php?action=register', 'login' );

// Append redirect URL if provided.
if ( ! empty( $redirect ) ) {
$register_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $register_url );
}

/**
* Filters the user registration URL.
*
* @since 3.6.0
*
* @param string $register The user registration URL.
*/
return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
return apply_filters( 'register_url', $register_url, $redirect );
}

/**
Expand Down
Loading