Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created September 7, 2022 22:24
Show Gist options
  • Save nikitasinelnikov/622816d671750ffd11eaa3aaa7ccb995 to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/622816d671750ffd11eaa3aaa7ccb995 to your computer and use it in GitHub Desktop.
Ultimate Member v3: Password Reset 'um_lostpassword_errors_hook' hook
// 'um_reset_password_errors_hook' - use action hook 'um_lostpassword_errors_hook' instead
/**
* Fires after Ultimate Member native Lost Password form validations are completed.
*
* Note: Use this hook for adding custom validations to your Lost Password form.
*
* Hook: um_lostpassword_errors_hook
*
* Type: action
*
* @package um\core
* @since 3.0.0
*
* @param array $lostpassword_form Frontend form class (\um\frontend\Form) instance.
*/
function my_lostpassword_errors_hook( $lostpassword_form ) {
// Flush all errors of the Lost Password form
$lostpassword_form->flush_errors();
// Add global form error
$lostpassword_form->add_error( 'global', __( 'Error description here', 'ultimate-member' ) );
// Add field-related error where 'user_login' is the field's id when form is inited see ultimate-member/includes/common/class-shortcodes.php line 156
$lostpassword_form->add_error( 'user_login', __( 'Error description here', 'ultimate-member' ) );
// Checking errors for the form
$lostpassword_form->has_errors();
}
add_action( 'um_lostpassword_errors_hook', 'my_lostpassword_errors_hook', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment