Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Created December 6, 2024 19:00
Show Gist options
  • Select an option

  • Save yuriinalivaiko/3979f4fb19bf42929d1043b257ff5e28 to your computer and use it in GitHub Desktop.

Select an option

Save yuriinalivaiko/3979f4fb19bf42929d1043b257ff5e28 to your computer and use it in GitHub Desktop.
Display all form errors in the popup.
<?php
/**
* Display all form errors in the popup.
*/
add_action( 'um_after_form', function () {
if ( ! empty( UM()->form()->errors ) ) {
$error_text = implode( '<br>', UM()->form()->errors );
?>
<div id="um_form_errors" style="display:none;">
<a href="javascript:void(0);" data-action="um_remove_modal" class="um-modal-close" aria-label="Close"><i class="um-faicon-times"></i></a>
<div class="um-modal-header">Form errors</div>
<div class="um-modal-body"><?php echo $error_text; ?></div>
</div>
<script type="text/javascript">
jQuery( window ).load( function() {
um_new_modal( 'um_form_errors', 'normal', false, '' );
} );
</script>
<?php
}
} );
@yuriinalivaiko
Copy link
Author

yuriinalivaiko commented Dec 6, 2024

This works on the profile edit.

Expected result
Display all form errors in the popup

See an alternative solution in the article Display all form errors below the form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment