User Guide | Message Configuration

The key concept of the flexi auth library is to give the developer a toolbox of functions that they can use to build a user authentication system matching the custom specifications required by their site.

One of the ways that the library enhances the customisation of the authentication system is by allowing many of the internal library settings to be defined by the developer via the libraries config file.

Message Configuration

Message Index | Message Functions

Message Delimiter Settings

Define status and error message delimiters to style auth messages.


Example
// Status Message Start Delimiter.
$config['messages']['delimiters']['status_prefix'] = <p class="status_msg">;

// Status Message End Delimiter.
$config['messages']['delimiters']['status_suffix'] = </p>;

// Error Message Start Delimiter.
$config['messages']['delimiters']['error_prefix'] = <p class="error_msg">;

// Error Message End Delimiter.
$config['messages']['delimiters']['error_suffix'] =  </p>;

Message Visibility

Define which status and error messages are returned as public or admin messages, or which messages are not returned at all.
Public messages are intended to be displayed to public and admin users, whilst admin messages are intended for admin users only.

Internal Message Name Default Value Description
account_creation_successful public Notifies that a user account has been successfully created.
account_creation_unsuccessful public Notifies that a user account could not be created.
account_creation_duplicate_email public Notifies that a user account could not be created due to a existing user with the same email address.
account_creation_duplicate_username public Notifies that a user account could not be created due to a existing user with the same username.
account_creation_duplicate_identity public Notifies that a user account could not be created due to a existing user with the same email address or username.
account_creation_insufficient_data public Notifies that a user account could not be created due to insufficient data being submitted.
password_invalid public Notifies that a supplied password failed the defined validation rules.
password_change_successful public Notifies that a users password was updated successfully.
password_change_unsuccessful public Notifies that a supplied password does not match the users current password, and so a new password could not be set.
password_token_invalid public Notifies that a validation token supplied whilst reseting a forgotten password was invalid or had expired.
email_new_password_successful public Notifies that a new password has been emailed to the user.
email_forgot_password_successful public Notifies that an email has been sent to reset the users password.
email_forgot_password_unsuccessful public Notifies that an email to reset the users password could not be sent.
activate_successful public Notifies that a users account has been activated.
activate_unsuccessful public Notifies that a users account could not be activated.
deactivate_successful public Notifies that a users account has been deactivated.
deactivate_unsuccessful public Notifies that a users account could not be deactivated.
activation_email_successful public Notifies that an account activation email has been sent to the user.
activation_email_unsuccessful public Notifies that an account activation email could not be sent to the user.
account_requires_activation public Notifies that a user must activate their account via email activation before they can login.
account_already_activated public Notifies that a user has already activated their account if they attempt to activate it again.
email_activation_email_successful public Notifies that a email has been sent to the user to verify their change of email address.
email_activation_email_unsuccessful public Notifies that a email could not be sent to the user to verify their change of email address.
login_successful public Notifies that a user has successfully logged into their account.
login_unsuccessful public Notifies that a user was not successfully logged into their account.
logout_successful public Notifies that a user has successfully logged out of their account.
login_details_invalid public Notifies that a users login details are invalid.
captcha_answer_invalid public Notifies that a users CAPTCHA answer is incorrect.
login_attempts_exceeded public Notifies a user the maximum failed login attempts to their account has been exceeded and that they must wait a short time before trying again.
login_session_expired public Notifies a user that their login session has expired and they will need to login again.
account_suspended public Notifies a user that their account has been suspended.
update_successful public Notifies that account information has been successfully updated.
update_unsuccessful public Notifies that account information could not be updated.
delete_successful public Notifies that account information has been successfully deleted.
delete_unsuccessful public Notifies that account information could not be deleted.
form_validation_duplicate_identity public Used by CodeIgniters native validation library.
Notifies that an account exists with either the same email address or username as with data from a specific input field.
form_validation_duplicate_email public Used by CodeIgniters native validation library.
Notifies that an account exists with the same email address as with data from a specific input field.
form_validation_duplicate_username public Used by CodeIgniters native validation library.
Notifies that an account exists with the same username as with data from a specific input field.
Example
// Set the message to be displayed to public users.
$config['messages']['target_user']['account_creation_successful'] = 'public';
// Set the message to be displayed to admin users only.
$config['messages']['target_user']['account_creation_successful'] = 'admin';
// Disable a message from being set.
$config['messages']['target_user']['account_creation_successful'] = FALSE;

Define Language

Define the language of status and error messages returned by flexi auth functions.


The Language File

flexi auth uses CodeIgniters language class to allow status and error messages returned by the library to be displayed in a specific language.

To set the library to display messages in a specific language, firstly the translated language file must be added to CodeIgniters 'language' directory. If the language you require does not currently exist, you will need to create a copy of the default language file and get it translated.


To do this, copy the 'English' language file from:
'application/language/english/flexi_auth_lang.php' to 'application/language/[YOUR LANGUAGE]/flexi_auth_lang.php'.


It is recommended that any translations are made directly from the English language file rather than others, as that contains the originally intended messages of the library, with no lingual misinterpretations.

If you are unable to translate the file yourself, you could try one of the many free translators that are available online:

Defining a Language

Defining the language used by the library is done using CodeIgniters internal methods, either via the CI config. file, or by using CI's language class.

// Example #1 : Set language via CI's config file ('application/config/config.php').
$config['language'] = 'spanish';
// Example #2 : Set language via CI's language class.
// Note: This must be defined before calling the flexi auth library and would typically be done in either
// a controller or model.

// First load the language file.
$this->lang->load('flexi_auth', 'spanish');

// And then load the flexi auth library.
$this->load->library('flexi_auth');