Skip to main content

Developer reference

Who this is for​

This page is for developers who need to extend the plugin using WordPress hooks and filters. Most users can accomplish everything through Settings without code.


Actions (hooks)​

Actions let you run custom code at specific points in the password reset flow.

ActionWhen it firesParametersUse for
somfrp_before_formBefore form HTMLNoneAdd notices, tracking
somfrp_after_formAfter form HTMLNoneAdd help text, links
somfrp_lost_pass_actionAfter email validation$user_infoAdmin notifications
somfrp_reset_pass_actionAfter password validation$user, $new_passLog changes, send emails

Examples​

Add custom notice before form:

add_action( 'somfrp_before_form', 'add_security_notice' );
function add_security_notice() {
echo '<div class="notice">For security, ensure your email is correct.</div>';
}

Send admin notification:

add_action( 'somfrp_lost_pass_action', 'notify_admin' );
function notify_admin( $user_info ) {
wp_mail(
get_option( 'admin_email' ),
'Password Reset Request',
"User $user_info requested password reset"
);
}

Log successful password changes:

add_action( 'somfrp_reset_pass_action', 'log_password_change', 10, 2 );
function log_password_change( $user, $new_pass ) {
// NEVER log the actual password!
update_user_meta( $user->ID, 'last_password_reset', current_time( 'mysql' ) );
}

Filters​

Filters let you modify data before the plugin uses it.

FilterWhat it modifiesParametersUse for
somfrp_retrieve_password_titleEmail subject$title, $user_login, $user_dataCustom subject lines
somfrp_retrieve_password_messageEmail body$message, $key, $user_login, $user_dataHTML emails, branding

Examples​

Customize email subject:

add_filter( 'somfrp_retrieve_password_title', 'custom_email_subject', 10, 3 );
function custom_email_subject( $title, $user_login, $user_data ) {
return sprintf( '[%s] Reset Your Password', get_bloginfo( 'name' ) );
}

Create HTML email:

add_filter( 'somfrp_retrieve_password_message', 'html_email', 10, 4 );
function html_email( $message, $key, $user_login, $user_data ) {
$reset_url = som_get_lost_password_url() . '?somresetpass=true&key=' . $key . '&uid=' . $user_data->ID;

return '<html><body style="font-family: Arial;">
<h2>Password Reset</h2>
<p>Hello ' . esc_html( $user_login ) . ',</p>
<p><a href="' . esc_url( $reset_url ) . '">Reset Password</a></p>
</body></html>';
}

Increase password reset link expiration time:

add_filter( 'password_reset_expiration', 'custom_password_reset_expiration', 10, 3 );
function custom_password_reset_expiration( $expiration_time, $user_id, $action ) {
// Set expiration time in seconds (e.g., 3 days = 259200 seconds)
return 259200; // Default is 24 hours (86400 seconds)
}
note

The password_reset_expiration filter is a WordPress core filter, not plugin-specific, but it works with Frontend Reset Password.


Helper functions​

som_get_lost_password_url()
Returns custom password reset page URL (from plugin settings).

$reset_url = som_get_lost_password_url();
echo '<a href="' . esc_url( $reset_url ) . '">Forgot Password?</a>';

Settings access​

Access plugin settings programmatically:

$general = get_option( 'somfrp_gen_settings' );
$security = get_option( 'somfrp_security_settings' );
$design = get_option( 'somfrp_design_settings' );

What's next​