Skip to:
Content
Pages
Categories
Search
Top
Bottom

Change error message display


  • imjscn
    Participant

    @imjscn

    Recently I learned a way to display error message by change the label color, I’d like to try it on bp.
    I need to know which file or function to look for the error types and message template. Could anybody help?

Viewing 7 replies - 1 through 7 (of 7 total)

  • Boone Gorges
    Keymaster

    @boonebgorges

    I’m not exactly sure what you mean by “the error types and messages”. There is no place in BP where all error types and messages are defined. Instead, the content of error messages is typically defined in the function where the error might occur. The error is then sent to the user like this:
    `bp_core_add_message( ‘This is where the error message goes’, ‘error’ );`
    Messages added in this way, in turn, are rendered on the page after the redirect.


    Virtuali
    Participant

    @gunju2221

    @imjscn, Color is CSS, therefore probably being in the buddypress default.css file?

    Probably Under:

    *Error/Success Messages



    find:

    }
    div#message.error p {
    background: #e41717;
    color: #fff;
    border-color: #a71a1a;
    clear: left;
    }

    It spells it out for you from there :)


    imjscn
    Participant

    @imjscn

    @boonebgorges
    I meant the error messages on register.php.

    If input is invalid, it adds a `

    `
    I don’t want to show the erro message. — this can be done by something like : .erro{ dispaly:none;}
    Then, If there’s any invalid input in this form, I want to add a line at the top of the form saying “invalid input, please review the input marked in red”;
    Then, I want to change the invalid field’s label color to red.
    I want to do this because I feel very annoyed seeing a big block of red message.


    imjscn
    Participant

    @imjscn

    @gunju2221
    It’s not css, it’s in the process of validation. I need to find which function deliver this error message, then I can work on changing the way it deliver.


    Boone Gorges
    Keymaster

    @boonebgorges

    @imjscn – There is no straightforward way to do what you’re trying to do.

    For the message at the top of the screen, you can change that with a language file and then change the display with CSS. Removing the class=”error” div will be more trouble than it’s worth.

    The other part will be harder. You can get the error info out of the $bp global – $bp->signup->errors – on page load. Then you’ll probably have to use Javascript to change the color of the labels.


    imjscn
    Participant

    @imjscn

    @boonebgorges
    I followed your suggestion, got the thing working! However, by my codes, I will have to write down each error for eah label color. Is there a way to run through all the erros and match it with label?
    Here’s what I’ve done so far:
    In the register.php, I test the signup name field by adding style to the label line like this:
    `<label for="signup_username" style="”> `
    In the bp-custom.php, I added this function:
    `<?php
    function elsa_bp_label_color( $errocolor ) {
    global $bp;
    if ( !empty( $bp->signup->errors ) )
    $errorcolor = ‘color:red’;
    else
    $errorcolor = ”;
    return $errorcolor;
    }
    ?>`

    Thanks for helping!


    imjscn
    Participant

    @imjscn

    I updated my code to include all the field I need to validate on the signup page:
    `<?php
    function elsa_err_username( ) {
    global $bp;
    if ( !empty( $bp->signup->errors ) )
    echo ‘color:red’;
    }
    add_action ( ‘elsa_err_username’,’elsa_err_username’ );

    function elsa_err_email( ){
    global $bp;
    if ( !empty( $bp->signup->errors ) )
    echo ‘color:red’;
    }
    add_action ( ‘elsa_err_email’,’elsa_err_email’ );

    function elsa_err_pass( ){
    global $bp;
    if ( !empty( $bp->signup->errors ) )
    echo ‘color:red’;
    }
    add_action ( ‘elsa_err_pass’,’elsa_err_pass’ );

    function elsa_err_x( ) {
    global $bp;
    if ( $field_id == 1 && !empty( $bp->signup->errors ) )
    echo ‘color:red’;
    else
    if ( !empty( $bp->signup->errors ) )
    echo ‘color:red’;
    }
    add_action ( ‘elsa_err_x’,’elsa_err_x’ );
    ?>`
    It get the result of changing the label color if there’s an error. But I guess there has to be a smart way to do it ?
    I also removed the line of “do_action(‘bp_ …. error”) which was below each label that need validate. I don’t know what else this line does beside creating a templete for displaying error message. ???
    Thanks for helping!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change error message display’ is closed to new replies.
Skip to toolbar