wc_lostpassword_url

Returns the url to the lost password endpoint url.

Description

(string) wc_lostpassword_url( (string) $default_url = '' ); 

Returns (string)

Parameters (1)

0. $default_url — Optional. (string) => ''
The default url.

Usage

  1. if ( !function_exists( 'wc_lostpassword_url' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-account-functions.php'; 
  3.  
  4. // The default url. 
  5. $default_url = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_lostpassword_url($default_url); 
  9.  

Defined (1)

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

/includes/wc-account-functions.php  
  1. function wc_lostpassword_url( $default_url = '' ) { 
  2. // Don't redirect to thewoocommerceendpoint on global network admin lost passwords. 
  3. if ( is_multisite() && isset( $_GET['redirect_to'] ) && false !== strpos( $_GET['redirect_to'], network_admin_url() ) ) { 
  4. return $default_url; 
  5.  
  6. $wc_account_page_url = wc_get_page_permalink( 'myaccount' ); 
  7. $wc_account_page_exists = wc_get_page_id( 'myaccount' ) > 0; 
  8. $lost_password_endpoint = get_option( 'woocommerce_myaccount_lost_password_endpoint' ); 
  9.  
  10. if ( $wc_account_page_exists && ! empty( $lost_password_endpoint ) ) { 
  11. return wc_get_endpoint_url( $lost_password_endpoint, '', $wc_account_page_url ); 
  12. } else { 
  13. return $default_url;