Skip to content

Instantly share code, notes, and snippets.

@nikitasinelnikov
Created September 8, 2022 12:07
Show Gist options
  • Save nikitasinelnikov/b732b3d541a9a6da3746ebf94a34334a to your computer and use it in GitHub Desktop.
Save nikitasinelnikov/b732b3d541a9a6da3746ebf94a34334a to your computer and use it in GitHub Desktop.
Ultimate Member v3: Password Reset 'um_resetpass_errors_hook' hook
// 'um_change_password_errors_hook' - use action hook 'um_resetpass_errors_hook' instead
/**
* Fires after Ultimate Member native Reset Password form validations are completed.
*
* Note: Use this hook for adding custom validations to your Reset Password form.
*
* Hook: um_resetpass_errors_hook
*
* Type: action
*
* @package um\core
* @since 3.0.0
*
* @param array $resetpass_form Frontend form class (\um\frontend\Form) instance.
*/
function my_resetpass_errors_hook( $resetpass_form ) {
// Flush all errors of the Reset Password form
$resetpass_form->flush_errors();
// Add global form error
$resetpass_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 75
$resetpass_form->add_error( 'user_login', __( 'Error description here', 'ultimate-member' ) );
// Checking errors for the form
$resetpass_form->has_errors();
}
add_action( 'um_resetpass_errors_hook', 'my_resetpass_errors_hook', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment