wp_login_url

Retrieves the login URL.

Description

(string) wp_login_url( (string) $redirect = '', (constant) $force_reauth = false ); 

Returns (string)

The login URL. Not HTML-encoded.

Parameters (2)

0. $redirect — Optional. (string) => ''
Path to redirect to on log in.
1. $force_reauth — Optional. (constant) => false
Whether to force reauthorization, even if a cookie is present. Default false.

Usage

  1. if ( !function_exists( 'wp_login_url' ) ) { 
  2. require_once ABSPATH . WPINC . '/general-template.php'; 
  3.  
  4. // Path to redirect to on log in. 
  5. $redirect = ''; 
  6.  
  7. // Whether to force reauthorization, even if a cookie is present. 
  8. // Default false. 
  9. $force_reauth = false; 
  10.  
  11. // NOTICE! Understand what this does before running. 
  12. $result = wp_login_url($redirect, $force_reauth); 
  13.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/general-template.php  
  1. function wp_login_url($redirect = '', $force_reauth = false) { 
  2. $login_url = site_url('wp-login.php', 'login'); 
  3.  
  4. if ( !empty($redirect) ) 
  5. $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url); 
  6.  
  7. if ( $force_reauth ) 
  8. $login_url = add_query_arg('reauth', '1', $login_url); 
  9.  
  10. /** 
  11. * Filters the login URL. 
  12. * @since 2.8.0 
  13. * @since 4.2.0 The `$force_reauth` parameter was added. 
  14. * @param string $login_url The login URL. Not HTML-encoded. 
  15. * @param string $redirect The path to redirect to on login, if supplied. 
  16. * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. 
  17. */ 
  18. return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );