I'm building a custom registration process in which a set of entries and a user are created at the same time.

Currently I'm not able to pass back my errors in my controller into the front-end template.

(The following code should error out on purpose to test this functionality)

In my plugin controller:

$user = new UserModel;
$wasSaved = craft()->users->saveUser($user);

if ($wasSaved) {
     $was_assigned = craft()->userGroups->assignUserToGroups($user->id, array(1));
} else {
     return false;

In my template

{% macro errorList(errors) %}
{% if errors %}
  <ul class="errors">
     {% for error in errors %}
         <li>{{ error }}</li>
      {% endfor %}
{% endif %}
{% endmacro %}

{% if account.getErrors is defined %}
    {{ _self.errorList(account.getErrors()) }}
{% endif %}

With the var_export($user->getErrors()); in my controller, I can see the errors at the top of the page:

array ( 'username' => array ( 0 => 'Username cannot be blank.', 1 => 'Username cannot be blank.', ),
'email' => array ( 0 => 'Email cannot be blank.', 1 => 'Email cannot be blank.', ), )

but these errors are not making it back into the actual template.

Any ideas?

1 Answer 1


It looks like you're not returning the user model back to the template.

You need something like this in your controller.

    'account' => $user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.