On this page
wp_login_url( string $redirect = '', bool $force_reauth = false ): string
Retrieves the login URL.
Parameters
$redirectstring Optional-
Path to redirect to on log in.
Default:
'' $force_reauthbool Optional-
Whether to force reauthorization, even if a cookie is present.
Default:
false
Return
string The login URL. Not HTML-encoded.
More Information
$redirect argument must be absolute, such as http://example.com/mypage/. For best results, use site_url( ‘/mypage/ ‘ ).
Source
File: wp-includes/general-template.php. View all references
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 );
}
Hooks
- apply_filters( 'login_url',
string $login_url ,string $redirect ,bool $force_reauth ) -
Filters the login URL.
Related
Uses
| Uses | Description |
|---|---|
| site_url() wp-includes/link-template.php | Retrieves the URL for the current site where WordPress application files (e.g. wp-blog-header.php or the wp-admin/ folder) are accessible. |
| add_query_arg() wp-includes/functions.php | Retrieves a modified URL query string. |
| apply_filters() wp-includes/plugin.php | Calls the callback functions that have been added to a filter hook. |
Used By
| Used By | Description |
|---|---|
| is_login() wp-includes/load.php | Determines whether the current request is for the login screen. |
| WP_Recovery_Mode_Link_Service::handle_begin_link() wp-includes/class-wp-recovery-mode-link-service.php | Enters recovery mode when the user hits wp-login.php with a valid recovery mode link. |
| WP_Recovery_Mode_Link_Service::get_recovery_mode_begin_url() wp-includes/class-wp-recovery-mode-link-service.php | Gets a URL to begin recovery mode. |
| wp_admin_bar_recovery_mode_menu() wp-includes/admin-bar.php | Adds a link to exit recovery mode when Recovery Mode is active. |
| wp_recovery_mode_nag() wp-admin/includes/update.php | Displays a notice when the user is in recovery mode. |
| wp_send_user_request() wp-includes/user.php | Send a confirmation request email to confirm an action. |
| WP_Customize_Manager::customize_pane_settings() wp-includes/class-wp-customize-manager.php | Prints JavaScript settings for parent window. |
| confirm_another_blog_signup() wp-signup.php | Shows a message confirming that the new site has been created. |
| network_step2() wp-admin/includes/network.php | Prints step 2 for Network installation process. |
| wp_new_blog_notification() wp-admin/includes/upgrade.php | Notifies the site admin that the installation of WordPress is complete. |
| wp_new_user_notification() wp-includes/pluggable.php | Emails login credentials to a newly-registered user. |
| auth_redirect() wp-includes/pluggable.php | Checks if a user is logged in, if not it redirects them to the login page. |
| wp_loginout() wp-includes/general-template.php | Displays the Log In/Out link. |
| wp_auth_check_html() wp-includes/functions.php | Outputs the HTML that shows the wp-login dialog when the user is no longer logged in. |
| register_new_user() wp-includes/user.php | Handles registering a new user. |
| wp_redirect_admin_locations() wp-includes/canonical.php | Redirects a variety of shorthand URLs to the admin. |
| wpmu_welcome_user_notification() wp-includes/ms-functions.php | Notifies a user that their account activation has been successful. |
| wpmu_validate_user_signup() wp-includes/ms-functions.php | Sanitizes and validates data required for a user sign-up. |
| wp_xmlrpc_server::initialise_blog_option_info() wp-includes/class-wp-xmlrpc-server.php | Set up blog options property. |
| get_post_reply_link() wp-includes/comment-template.php | Retrieves HTML content for reply to post link. |
| comment_form() wp-includes/comment-template.php | Outputs a complete commenting form for use within a template. |
| get_comment_reply_link() wp-includes/comment-template.php | Retrieves HTML content for reply to comment link. |
Changelog
| Version | Description |
|---|---|
| 2.7.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_login_url