Plugin/Events/User

From Joomla! Documentation

< Plugin‎ | Events
Copyedit.png
This Article Needs Your Help

This article is tagged because it NEEDS UPDATING. You can help the Joomla! Documentation Wiki by contributing to it.
More pages that need help similar to this one are here. NOTE-If you feel the need is satistified, please remove this notice.

Reason: Page is based on 1.5 and needs updating, links point to 1.5 api and are broken.


In a standard installation of Joomla! we have several predefined User events which, when triggered, call functions in the associated plugins.

onUserLogin[edit]

Description[edit]

This event is triggered after the user is authenticated against the Joomla! user-base.

If you need to abort the login process (authentication), you will need to use onUserAuthenticate instead.

Parameters[edit]

  • $user - an associative array of JAuthenticateResponse type (see link for array keys)
  • $options - an associative array containing these keys: ["remember"] => bool, ["return"] => string, ["entry_url"] => string

Return Value[edit]

Boolean

Used in files[edit]

  • libraries/joomla/application/application.php
  • plugins/user/joomla.php

Examples[edit]

  • plugins/user/example.php

onUserLogout[edit]

Description[edit]

This event is triggered before the user is logged out of the system. If one plugin returns false, the global logout fails. (needs verification)

Parameters[edit]

  • $credentials - an associative array containing these keys: ["username"] => string, ["id"] => int
  • $options - an associative array containing this key: ["clientid"] => int

Return Value[edit]

Boolean

Used in files[edit]

  • libraries/joomla/application/application.php
  • plugins/user/joomla.php

Examples[edit]

  • plugins/user/example.php

onUserAuthenticate[edit]

Description[edit]

This event is triggered to verify that a set of login credentials is valid.

Parameters[edit]

Array of credentials. Structure:\\ ['username']\\ ['password']\\ Alternative authentication mechanisms can supply additional credentials.

Return Value[edit]

An array of JAuthenticateResponse objects detailing the results of each called plugin, including success or failure.

Used in files[edit]

  • libraries/joomla/application/user/authentication.php
  • plugins/authentication/gmail.php
  • plugins/authentication/joomla.php
  • plugins/authentication/ldap.php

Examples[edit]

  • plugins/authentication/example.php

onUserLoginFailure[edit]

Description[edit]

This event is triggered whenever a user authentication request is failed by any plugin.

Parameters[edit]

Two parameters. The credentials array for the user (see onAuthenticate), and the JAuthenticateResponse that caused the failure.

Return Value[edit]

Unknown. The return value appears to be ignored in any case.

Used in files[edit]

  • libraries/joomla/application/user/authentication.php

onUserAfterLogin[edit]

Description[edit]

This event is triggered whenever a user is successfully logged in.

Parameters[edit]

Options is array with:

  • remember
  • return
  • entry_url
  • action
  • user - JUser Object
  • responseType

Return Value[edit]

Boolean

Used in files[edit]

  • libraries/legacy/application/application.php
  • libraries/cms/application/cms.php
  • plugins/authentication/cookie/cookie.php

onUserBeforeSave[edit]

Description[edit]

This event is triggered before an update of a user record.

password in $newUser array is already hashed at this point. You may retrieve the cleartext password using the password_clear field in that array. (password_clear is only set to a meaningful value if the user has just changed their password; otherwise it will be blank.)

Parameters[edit]

  • $oldUser - An associative array of the columns in the user table (current values).
  • $isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)
  • $newUser - An associative array of the columns in the user table (new values).

Return Value[edit]

Boolean. Whether the user-save should proceed or not. Any plugin that returns false aborts the save.

Used in files[edit]

  • libraries/joomla/user/user.php

Examples[edit]

  • plugins/user/example.php

onUserAfterSave[edit]

Description[edit]

This event is triggered after an update of a user record, or when a new user has been stored in the database.

Password in $user array is already hashed at this point. You may retrieve the cleartext password using $_POST['password'].

Parameters[edit]

  • $user - An associative array of the columns in the user table.
  • $isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)
  • $success - Boolean to identify if the store was successful
  • $msg - Error message if store failed

Note: The old values that were just updated are not available here or afterwards. In case you need the old values, use onBeforeStoreUser().

Return Value[edit]

None

Used in files[edit]

  • libraries/joomla/user/user.php

Examples[edit]

  • plugins/user/example.php

onUserBeforeDelete[edit]

Description[edit]

The event is triggered when a user is about to be deleted from the system.

Parameters[edit]

  • $user - An associative array of the columns in the user table.

Return Value[edit]

None.

Used in files[edit]

  • libraries/joomla/user/user.php
  • plugins/user/joomla.php

Examples[edit]

  • plugins/user/example.php

onUserAfterDelete[edit]

Description[edit]

The event is triggered after a user has been deleted from the system.

Parameters[edit]

  • $user - An associative array of the columns in the user table.
  • $succes - Boolean to identify if the deletion was successful
  • $msg - Error message if delete failed (JError object detailing the error, if any)

Return Value[edit]

None.

Used in files[edit]

  • libraries/joomla/user/user.php
  • plugins/user/joomla.php

Examples[edit]

  • plugins/user/example.php