Show error messages

Hi everybody!

I just started to develop my elgg application and I was wondering how to show error messages. I have been reading the documentation but I didn't find how to show error messages. Particularly, I have used the custom_index plugin in order to develop a nicer index page. In the index page, I have included the login form but I can not show the error when the user/pass are incorrect.

This is my login form extracted from my index page:

<form class="form-2" action="action/login" method="post">
$ts = time();
$token = generate_action_token($ts);
echo $vars;
                    <p class="clearfix" style="margin: 10px;">
                        <h4 style="color:#646464;">Bienvenido a BVMC Community!</h4>
                    <p class="clearfix" style="margin: 10px;">
                        <span class="icon bvmc fa-user" style=""></span>
                    <p class="clearfix" style="margin: 10px;">
                        <!--<label for="login">Usuario</label> -->
                        <input type="text" name="username" id="login" placeholder="Usuario" required>
                    <p class="clearfix" style="margin: 10px;">
                        <!--<label for="password">Password</label>-->
                        <input type="password" name="password" id="password" placeholder="Password" required> 

                    <input type="hidden" name="__elgg_token" value="<?php echo $token; ?>"/>
                    <input type="hidden" name="__elgg_ts" value="<?php echo $ts; ?>" />
                    <p class="clearfix" style="margin: 10px;">
                        <input type="submit" name="submit" value="Entrar">

If I go to the traditional login page I can see the errors if I use the wrong username.

This might be something easy but I just can't find the solution...

Thanks for your time!

  • Coz you hasn't using elgg_view_layout() and form view

    Just look at custom index construction:

    //grab the login form
    $login = elgg_view("core/account/login_box");
    // lay out the content
    $params = array(
        'login' => $login,
    $body = elgg_view_layout('custom_index', $params);
    echo elgg_view_page('', $body);


  • I also struggled for the same thing for 3-4 days and then finally found a solution.

    1. On top of your php file add the following code:

    $system_messages = _elgg_services()->systemMessages->dumpRegister();
    system_messages(null, "");

    2. Now add the following code where you want to display the error message:

    if (isset($system_messages['error'])) {
        foreach($system_messages['error'] as $sysmsg){
            echo "<b><font color='red'>$sysmsg</font><b>";
    if (isset($system_messages['success'])) {
        foreach($system_messages['success'] as $sysmsg){
            echo "<b><font color='green'>$sysmsg</font></b>";


    1. I have tried and tested this in elgg 1.12. Not sure if this will work on any other version or not.
    2. This will not display the error/success message as popups that is normally shown in elgg but rather as text which will be part of your content on your webpage.
  • Thanks for your fast response!

    My index page is completely a new view and although it might be better to use RVR approach, as I don't have much time to do the index from scratch using elgg views, I have used Rogit Gupta solution.

    I will keep in touch for my next doubts or suggestions :)

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking