• LifterLMS
  • Knowledge Base
  • Academy
  • Blog
  • Podcast
  • Contributors

LifterLMS LifterLMS

Code Reference

  • Home
  • Code Reference
Skip to content
Filter by type:
Search
Browse: Home / Code Reference / Classes / LLMS_Controller_Account / LLMS_Controller_Account::reset_password()

LLMS_Controller_Account::reset_password()

Handle form submission of the Reset Password form This is the form that actually updates a users password

Contents

  • Description
    • Return
    • Source
    • Changelog
  • Related
    • Uses
  • User Contributed Notes

Description #Description


Return #Return

(void)


Top ↑

Source #Source

File: includes/forms/controllers/class.llms.controller.account.php

	public function reset_password() {

		// invalid nonce or the form wasn't submitted
		if ( ! llms_verify_nonce( '_reset_password_nonce', 'llms_reset_password', 'POST' ) ) {
			return;
		}

		$valid = LLMS_Person_Handler::validate_fields( $_POST, 'reset_password' );

		// validation or registration issues
		if ( is_wp_error( $valid ) ) {
			foreach ( $valid->get_error_messages() as $msg ) {
				llms_add_notice( $msg, 'error' );
			}
			return;
		}

		$login = trim( sanitize_text_field( $_POST['llms_reset_login'] ) );

		if ( ! llms_verify_password_reset_key( trim( sanitize_text_field( $_POST['llms_reset_key'] ) ), $login ) ) {
			return llms_add_notice( __( 'Invalid Key', 'lifterlms' ), 'error' );
		}

		$pass = $_POST['password'];
		$user = get_user_by( 'login', $login );

		if ( ! $user ) {
			return llms_add_notice( __( 'Invalid Key', 'lifterlms' ), 'error' );
		}

		do_action( 'password_reset', $user, $pass );

		wp_set_password( $pass, $user->ID );

		wp_password_change_notification( $user );

		llms_add_notice( sprintf( __( 'Your password has been updated. %1$sClick here to login%2$s', 'lifterlms' ), '<a href="' . esc_url( llms_get_page_url( 'myaccount' ) ) . '">', '</a>' ) );

	}

Expand full source code Collapse full source code View on GitHub


Top ↑

Changelog #Changelog

Changelog
Version Description
3.8.0 Introduced.

Top ↑

Related #Related

Top ↑

Uses #Uses

Uses
Uses Description
includes/llms.functions.core.php: llms_verify_nonce()

Verify nonce with additional checks to confirm request method Skips verification if the nonce is not set Useful for checking nonce for various LifterLMS forms which check for the form submission on init actions

includes/llms.functions.core.php: llms_verify_password_reset_key()

Verifies a plain text password key for a user (by login) against the hashed key in the database

includes/class.llms.person.handler.php: LLMS_Person_Handler::validate_fields()

Validate submitted user data for registration or profile updates

includes/functions/llms.functions.notice.php: llms_add_notice()

Stores notice in llms_notices session

includes/functions/llms.functions.page.php: llms_get_page_url()

Retrieve the URL for a LifterLMS Page EG: ‘checkout’, ‘memberships’, ‘myaccount’, ‘courses’ etc.


Top ↑

User Contributed Notes #User Contributed Notes

You must log in before being able to contribute a note or feedback.





Permalink:
© 2014 - 2019 LifterLMS · Privacy Policy · Terms and Conditions