• Resolved palopoliart7

    (@palopoliart7)


    Hello, I would like to show a red ERROR MESSAGE on the top of the Register page when a person tries to submit without all required field.

    For now, it comes back to the top of the page but if we don’t scroll down there is no way to know there are missing fields and it has not been sent.

    Can you help me find a way to show the error message on the top of page when it happens ? So the user know they have to scroll down to check missing input fields.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter palopoliart7

    (@palopoliart7)

    Update : I tried to use the hook um_before_form to add all errors before the form like this :

    /**
     * Display all form errors before the form.
     */
    add_action( 'um_before_form', 'um_display_all_form_errors',10,1 );
    function um_display_all_form_errors( $args = array() ) {
    	if ( ! empty( UM()->form()->errors ) ) {
    		foreach ( UM()->form()->errors as $key => $error_text ) {
    			echo UM()->fields()->field_error( $error_text );
    		}
    	}
    }

    But it does not work.

    When I use the hook um_after_form, it works and shows errors in the end of the form, but that’s not what I want. I want all errors to show on the top of the form.

    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hello @palopoliart7

    Set the second parameter $force_show to true if you need to show the field error message before the field is shown.

    /**
     * Display all form errors above the form.
     */
    add_action( 'um_before_form', 'um_display_all_form_errors' );
    function um_display_all_form_errors( $args = array() ) {
    	if ( ! empty( UM()->form()->errors ) ) {
    		$force_show = true;
    		foreach ( UM()->form()->errors as $key => $error_text ) {
    			echo UM()->fields()->field_error( $error_text, $force_show );
    		}
    	}
    }

    Regards

    Plugin Support yuriinalivaiko

    (@yuriinalivaiko)

    Hi palopoliart7

    This thread has been inactive for a while so we’re going to go ahead and mark it Resolved.

    Please feel free to re-open this thread if any other questions come up and we’d be happy to help.

    Regards

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show error message on top of register form’ is closed to new replies.