login_urlfilter-hookWP 2.8.0

Allows you to change the login page URL (link).

Usage

add_filter( 'login_url', 'wp_kama_login_url_filter', 10, 3 );

/**
 * Function for `login_url` filter-hook.
 * 
 * @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 string
 */
function wp_kama_login_url_filter( $login_url, $redirect, $force_reauth ){

	// filter...
	return $login_url;
}
$login_url(string)
The login URL. Not HTML-encoded.
$redirect(string)
The URL to redirect to after authorization/login. If this URL is not specified, no redirect occurs.
$force_reauth(true|false)
Whether to force reauthorization even if a cookie is present.

Examples

#1 Login link on a WooCommerce site

// Login link on a site with WooCommerce
add_filter( 'login_url', 'wp_kama_wc_login_url', 10, 3 );

function wp_kama_wc_login_url( $login_url, $redirect, $force_reauth ) {

	if ( $redirect ) {
		$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), wc_get_page_permalink( 'myaccount' ) );
	}

	return $login_url;
}

Changelog

Since 2.8.0 Introduced.
Since 4.2.0 The $force_reauth parameter was added.

Where the hook is called

wp_login_url()
login_url
wp-includes/general-template.php 669
return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );

Where the hook is used in WordPress

Usage not found.