The 'recovery_mode_email_link_ttl'
filter allows you to change the amount of time a recovery mode email link is valid for in a WordPress site. The time-to-live (TTL) must be at least as long as the email rate limit.
Usage
add_filter( 'recovery_mode_email_link_ttl', 'your_function_name' );
Parameters
$valid_for
(int): The number of seconds the link is valid for.
Examples
Extending Recovery Mode Email Link TTL to 2 Hours
function extend_recovery_mode_email_link_ttl( $valid_for ) { return 2 * HOUR_IN_SECONDS; } add_filter( 'recovery_mode_email_link_ttl', 'extend_recovery_mode_email_link_ttl' );
This code changes the default recovery mode email link TTL to 2 hours.
Setting Recovery Mode Email Link TTL to 30 Minutes
function set_recovery_mode_email_link_ttl( $valid_for ) { return 30 * MINUTE_IN_SECONDS; } add_filter( 'recovery_mode_email_link_ttl', 'set_recovery_mode_email_link_ttl' );
This code sets the recovery mode email link TTL to 30 minutes.
Using a Custom Recovery Mode Email Link TTL
function custom_recovery_mode_email_link_ttl( $valid_for ) { $custom_ttl = get_option( 'custom_recovery_mode_email_link_ttl' ); return $custom_ttl * MINUTE_IN_SECONDS; } add_filter( 'recovery_mode_email_link_ttl', 'custom_recovery_mode_email_link_ttl' );
This code retrieves a custom recovery mode email link TTL value from the site’s options and applies it.
Disabling Recovery Mode Email Link
function disable_recovery_mode_email_link( $valid_for ) { return 0; } add_filter( 'recovery_mode_email_link_ttl', 'disable_recovery_mode_email_link' );
This code disables the recovery mode email link by setting the TTL to 0 seconds.
Using a Recovery Mode Email Link TTL Based on User Role
function user_role_based_recovery_mode_email_link_ttl( $valid_for ) { $user = wp_get_current_user(); if ( in_array( 'administrator', $user->roles ) ) { return 2 * HOUR_IN_SECONDS; } else { return 30 * MINUTE_IN_SECONDS; } } add_filter( 'recovery_mode_email_link_ttl', 'user_role_based_recovery_mode_email_link_ttl' );
This code sets the recovery mode email link TTL to 2 hours for administrators and 30 minutes for other users.