Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
significance: patch
type: fixed
links:
- "#2741"
entry: Avoid modifying the Lost Password link if no LifterLMS Dashboard page is set.
13 changes: 2 additions & 11 deletions includes/class.llms.person.handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ protected static function find_password_fields( $location ) {
}

return $fields;

}

/**
Expand Down Expand Up @@ -120,7 +119,7 @@ public static function generate_username( $email ) {
while ( username_exists( $username ) ) {

$username = $orig_username . $i;
$i++;
++$i;

}

Expand All @@ -133,7 +132,6 @@ public static function generate_username( $email ) {
* @param string $email User's email address which was used to generate the username.
*/
return apply_filters( 'lifterlms_generated_username', $username, $email );

}

/**
Expand Down Expand Up @@ -196,13 +194,12 @@ public static function get_login_fields( $layout = 'columns' ) {
'columns' => ( 'columns' == $layout ) ? 3 : 6,
'id' => 'llms_lost_password',
'last_column' => true,
'description' => '<a href="' . esc_url( llms_lostpassword_url() ) . '">' . __( 'Lost your password?', 'lifterlms' ) . '</a>',
'description' => '<a href="' . esc_url( wp_lostpassword_url() ) . '">' . __( 'Lost your password?', 'lifterlms' ) . '</a>',
'type' => 'html',
'wrapper_classes' => 'align-right',
),
)
);

}

/**
Expand Down Expand Up @@ -264,7 +261,6 @@ public static function get_lost_password_fields() {
),
)
);

}

/**
Expand Down Expand Up @@ -313,7 +309,6 @@ private static function get_password_fields() {
);

return $fields;

}

/**
Expand Down Expand Up @@ -381,7 +376,6 @@ public static function get_password_reset_fields( $key = '', $login = '' ) {
* set of fields is generated programmatically.
*/
return apply_filters( 'llms_password_reset_fields', $fields, $key, $login, $location );

}

/**
Expand Down Expand Up @@ -483,7 +477,6 @@ public static function login( $data ) {
}

return $signon->ID;

}

/**
Expand Down Expand Up @@ -533,7 +526,6 @@ protected static function validate_login_fields( $data ) {
* @param array $data User submitted login data.
*/
return apply_filters( 'llms_after_user_login_data_validation', $valid, $data );

}

/**
Expand All @@ -551,5 +543,4 @@ public static function get_available_fields( $screen = 'registration', $data = a
_deprecated_function( 'LLMS_Person_Handler::get_available_fields()', '5.0.0', 'LLMS_Forms::get_form_fields()' );
return LLMS_Forms::instance()->get_form_fields( $screen );
}

}
5 changes: 1 addition & 4 deletions includes/emails/class.llms.email.reset.password.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public function init( $args = array() ) {
'{user_login}' => $args['login_display'],
)
);

}

/**
Expand All @@ -60,7 +59,7 @@ public function get_body_content( $data ) {
'key' => $data['key'],
'login' => rawurlencode( $data['user']->user_login ),
),
llms_lostpassword_url()
wp_lostpassword_url()
)
);

Expand All @@ -72,7 +71,5 @@ public function get_body_content( $data ) {
)
);
return ob_get_clean();

}

}
12 changes: 1 addition & 11 deletions includes/forms/controllers/class.llms.controller.account.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public function __construct() {
add_action( 'init', array( $this, 'reset_password' ) );
add_action( 'init', array( $this, 'cancel_subscription' ) );
add_action( 'init', array( $this, 'redeem_voucher' ) );

}

/**
Expand Down Expand Up @@ -88,7 +87,6 @@ public function cancel_subscription() {
* @param integer $uid The WP_User ID the student who cancelled the subscription.
*/
do_action( 'llms_subscription_cancelled_by_student', $order, $uid );

}

/**
Expand Down Expand Up @@ -135,7 +133,6 @@ public function update() {
llms_redirect_and_exit( apply_filters( 'lifterlms_update_account_redirect', llms_get_endpoint_url( 'edit-account', '', llms_get_page_url( 'myaccount' ) ) ) );

}

}

/**
Expand Down Expand Up @@ -247,7 +244,6 @@ public function lost_password() {
// Success.
llms_add_notice( __( 'Check your e-mail for the confirmation link.', 'lifterlms' ) );
return true;

}

/**
Expand Down Expand Up @@ -275,7 +271,6 @@ public function redeem_voucher() {

llms_add_notice( __( 'Voucher redeemed successfully!', 'lifterlms' ), 'success' );
return true;

}

/**
Expand Down Expand Up @@ -306,7 +301,6 @@ public function reset_password() {
// Success.
llms_add_notice( __( 'Your password has been updated.', 'lifterlms' ) );
llms_redirect_and_exit( add_query_arg( 'password-reset', 1, llms_get_page_url( 'myaccount' ) ) );

}

/**
Expand Down Expand Up @@ -377,7 +371,6 @@ private function reset_password_handler() {
do_action( 'llms_user_password_reset', $user );

return true;

}

/**
Expand All @@ -403,9 +396,8 @@ public function reset_password_link_redirect() {

( new LLMS_Cache_Helper() )->maybe_no_cache();
llms_set_password_reset_cookie( $val );
llms_redirect_and_exit( add_query_arg( 'reset-pass', 1, llms_lostpassword_url() ) );
llms_redirect_and_exit( add_query_arg( 'reset-pass', 1, wp_lostpassword_url() ) );
}

}

/**
Expand Down Expand Up @@ -452,9 +444,7 @@ protected function validate_password_reset( $posted_data ) {
}

return true;

}

}

return new LLMS_Controller_Account();
13 changes: 6 additions & 7 deletions includes/functions/llms.functions.page.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ function llms_cancel_payment_url() {

$cancel_payment_url = esc_url( get_permalink( llms_get_page_id( 'checkout' ) ) );
return apply_filters( 'lifterlms_checkout_confirm_payment_url', $cancel_payment_url );

}

/**
Expand Down Expand Up @@ -59,7 +58,6 @@ function llms_confirm_payment_url( $order_key = null ) {
* @param string $url URL to the payment confirmation screen.
*/
return apply_filters( 'lifterlms_checkout_confirm_payment_url', $url );

}

/**
Expand Down Expand Up @@ -180,7 +178,6 @@ function _llms_normalize_endpoint_base_url( $url, $endpoint ) {
}

return $url;

}

/**
Expand Down Expand Up @@ -221,7 +218,6 @@ function llms_get_page_id( $page ) {
$page = apply_filters( "lifterlms_get_{$page}_page_id", $id );

return $page ? absint( $page ) : -1;

}


Expand Down Expand Up @@ -249,10 +245,14 @@ function llms_get_page_url( $page, $args = array() ) {
*
* @return string
*/
function llms_lostpassword_url() {
function llms_lostpassword_url( $lostpassword_url ) {
if ( llms_get_page_id( 'myaccount' ) <= 0 || ! get_permalink( llms_get_page_id( 'myaccount' ) ) ) {
return $lostpassword_url;
}

return llms_get_endpoint_url( 'lost-password', '', get_permalink( llms_get_page_id( 'myaccount' ) ) );
}
add_filter( 'lostpassword_url', 'llms_lostpassword_url', 10, 0 );
add_filter( 'lostpassword_url', 'llms_lostpassword_url', 10, 1 );

/**
* Returns the page number query var for the current request.
Expand All @@ -278,5 +278,4 @@ function llms_get_paged_query_var() {
$paged = 1;
}
return (int) $paged;

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected function set_merge_data( $code ) {
break;

case '{{PASSWORD_RESET_URL}}':
$code = llms_lostpassword_url();
$code = wp_lostpassword_url();
break;

case '{{SITE_TITLE}}':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ public function test_reset_password_link_redirect_success_fake_user() {
) );

$this->expectException( LLMS_Unit_Test_Exception_Redirect::class );
$this->expectExceptionMessage( add_query_arg( 'reset-pass', 1, llms_lostpassword_url() ) . ' [302] YES' );
$this->expectExceptionMessage( add_query_arg( 'reset-pass', 1, wp_lostpassword_url() ) . ' [302] YES' );

try {

Expand Down Expand Up @@ -950,7 +950,7 @@ public function test_reset_password_link_redirect_success_real_user() {
) );

$this->expectException( LLMS_Unit_Test_Exception_Redirect::class );
$this->expectExceptionMessage( add_query_arg( 'reset-pass', 1, llms_lostpassword_url() ) . ' [302] YES' );
$this->expectExceptionMessage( add_query_arg( 'reset-pass', 1, wp_lostpassword_url() ) . ' [302] YES' );

try {

Expand Down