# Remind Administrators to Change Old Passwords

> Shows administrators a reminder when they have not changed their password for 180 days.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: security, passwords, notices
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/remind-admins-old-passwords/

## Code

```php
// Days before the reminder appears.
$wpide_password_max_age = 180;

add_action( 'after_password_reset', function ( $user ) {
    update_user_meta( $user->ID, 'wpide_password_changed', time() );
} );

add_action( 'profile_update', function ( $user_id, $old_user ) {
    $user = get_userdata( $user_id );

    if ( $user && $old_user && $user->user_pass !== $old_user->user_pass ) {
        update_user_meta( $user_id, 'wpide_password_changed', time() );
    }
}, 10, 2 );

add_action( 'admin_notices', function () use ( $wpide_password_max_age ) {
    if ( ! current_user_can( 'manage_options' ) ) {
        return;
    }

    $user_id = get_current_user_id();
    $changed = (int) get_user_meta( $user_id, 'wpide_password_changed', true );

    if ( ! $changed ) {
        update_user_meta( $user_id, 'wpide_password_changed', time() ); // Start counting from today.
        return;
    }

    if ( time() - $changed > $wpide_password_max_age * DAY_IN_SECONDS ) {
        printf(
            '<div class="notice notice-warning"><p>You have not changed your password in over %1$d days. <a href="%2$s">Choose a new one</a>.</p></div>',
            (int) $wpide_password_max_age,
            esc_url( admin_url( 'profile.php#password' ) )
        );
    }
} );
```

## Notes

The count starts the first time each administrator opens the dashboard after activation.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remind Administrators to Change Old Passwords" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
