Prints form errors in a notice if necessary.
Description
See also
Parameters
- $form
-
(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Form object.
Source
File: src/db-objects/forms/form-frontend-output-handler.php
protected function maybe_print_form_error( $form ) { $key = $this->form_manager->get_prefix() . 'form_errors'; if ( is_user_logged_in() ) { $errors = get_user_meta( get_current_user_id(), $key, true ); if ( is_array( $errors ) && isset( $errors[ $form->id ] ) ) { $this->print_notice( $errors[ $form->id ], 'error' ); if ( count( $errors ) === 1 ) { delete_user_meta( get_current_user_id(), $key ); } else { unset( $errors[ $form->id ] ); update_user_meta( get_current_user_id(), $key, $errors ); } } return; } if ( isset( $_SESSION ) && isset( $_SESSION[ $key ] ) && isset( $_SESSION[ $key ][ $form->id ] ) ) { $this->print_notice( $_SESSION[ $key ][ $form->id ], 'error', true ); if ( count( $_SESSION[ $key ] ) === 1 ) { unset( $_SESSION[ $key ] ); } else { unset( $_SESSION[ $key ][ $form->id ] ); } } }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |