Skip to content

Commit

Permalink
Set user password expiration date on password reset.
Browse files Browse the repository at this point in the history
See #3406.
  • Loading branch information
boonebgorges committed Jul 16, 2024
1 parent 20f8360 commit 7e17d74
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions wp-content/plugins/wds-citytech/includes/passwords.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

namespace OpenLab\Passwords;

/**
* Gets the password expiration interval.
*
* @return int The interval in seconds.
*/
function get_password_expiration_interval() {
return 180 * DAY_IN_SECONDS;
}

/**
* Sets a user's password expiration date.
*
Expand Down Expand Up @@ -194,3 +203,15 @@ function password_expired_message( $message ) {
return $message;
}
add_filter( 'login_message', __NAMESPACE__ . '\password_expired_message' );

/**
* Sets the user's password expiration date when they reset their password.
*
* @param \WP_User $user The user object.
* @return void
*/
function set_password_expiration_on_password_reset( $user ) {
$expiration = time() + get_password_expiration_interval();
set_password_expiration( $user->ID, $expiration );
}
add_action( 'after_password_reset', __NAMESPACE__ . '\set_password_expiration_on_password_reset' );

0 comments on commit 7e17d74

Please sign in to comment.