wp_login_url() WordPress Function

The wp_login_url() function allows you to easily create a login URL for your WordPress site. Simply pass in the desired URL as the first argument, and the URL will be returned as a properly formatted login URL. You can also optionally specify a redirect URL as the second argument, which will be used after the user logs in.

wp_login_url( string $redirect = '', bool $force_reauth = false ) #

Retrieves the login URL.


Parameters

$redirect

(string)(Optional)Path to redirect to on log in.

Default value: ''

$force_reauth

(bool)(Optional)Whether to force reauthorization, even if a cookie is present.

Default value: false


Top ↑

Return

(string) The login URL. Not HTML-encoded.


Top ↑

More Information

$redirect argument must be absolute, such as http://example.com/mypage/. For best results, use site_url( ‘/mypage/ ‘ ).


Top ↑

Source

File: wp-includes/general-template.php

function wp_login_url( $redirect = '', $force_reauth = false ) {
	$login_url = site_url( 'wp-login.php', 'login' );

	if ( ! empty( $redirect ) ) {
		$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
	}

	if ( $force_reauth ) {
		$login_url = add_query_arg( 'reauth', '1', $login_url );
	}

	/**
	 * Filters the login URL.
	 *
	 * @since 2.8.0
	 * @since 4.2.0 The `$force_reauth` parameter was added.
	 *
	 * @param string $login_url    The login URL. Not HTML-encoded.
	 * @param string $redirect     The path to redirect to on login, if supplied.
	 * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
	 */
	return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More