Created
December 6, 2024 19:00
-
-
Save yuriinalivaiko/3979f4fb19bf42929d1043b257ff5e28 to your computer and use it in GitHub Desktop.
Display all form errors in the popup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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 | |
| } | |
| } ); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works on the profile edit.
Expected result

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