J1.5

Difference between revisions of "Plugin/Events/User"

From Joomla! Documentation

< J1.5:Plugin/Events
(Grammar)
(34 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Development]]
+
{{RightTOC}}
[[Category:Plugins]]
 
==5.3 User Events for Plugin System==
 
  
===5.3.1 Overview===
+
{{Warning|This page is under migration to Joomla 2.5 new plugin trigger methods}}
In a standard installation of Joomla! 1.5 we have several predefined events which, when triggered, call functions in the associated plugins. For more information on plugins,
+
 
look [[plugins:create_plugin|here]].
+
In a standard installation of Joomla! 2.5 we have several predefined events which, when triggered, call functions in the associated plugins.
  
 
The user events are divided into two parts. First we have the events used while  
 
The user events are divided into two parts. First we have the events used while  
 
authentication of a user takes place:
 
authentication of a user takes place:
  *onLoginUser
+
*onUserLogin (on Joomla 1.5: onLoginUser)
  *onLogoutUser
+
*onUserLogout (on Joomla 1.5: onLogoutUser)
  *onAuthenticate
+
*onUserAuthenticate (on Joomla 1.5: onAuthenticate)
  *onAuthenticateFailure
+
*onUserAuthorisationFailure (on Joomla 1.5: onAuthenticateFailure)
 
    
 
    
 
Second we have the events triggered during user management:
 
Second we have the events triggered during user management:
  *onBeforeStoreUser
+
*onUserBeforeSave (on Joomla 1.5: onBeforeStoreUser)
  *onAfterStoreUser
+
*onUserAfterSave (on Joomla 1.5: onAfterStoreUser)
  *onBeforeDeleteUser
+
*onUserBeforeDelete (on Joomla 1.5: onBeforeDeleteUser)
  *onAfterDeleteUser
+
*onUserAfterDelete (on Joomla 1.5: onAfterDeleteUser)
  
===5.3.2 onLoginUser===
+
==onUserLogin==
====5.3.2.1 Description====
+
===Description===
 
This event is triggered after the user is authenticated against the Joomla! user-base.
 
This event is triggered after the user is authenticated against the Joomla! user-base.
If one plugin returns false, the entire authentication process fails.
 
====5.3.2.2 Parameters====
 
Two parameters: $user, and $options.
 
  
*User is an array of [http://api.joomla.org/Joomla-Framework/User/JAuthenticationResponse.html JAuthenticateResponse]
+
If you need to abort the login process (authentication), you will need to use [http://docs.joomla.org/Reference:User_Events_for_Plugin_System#5.3.4_onAuthenticate onAuthenticate] instead.
object type (see link for array variables)
 
*Options is an options array containing these keys: ["remember"] => bool, ["return"] => string, ["entry_url"] => string
 
  
====5.3.2.3 Return Value====
+
===Parameters===
 +
* $user - an associative array of [http://api.joomla.org/Joomla-Framework/User/JAuthenticationResponse.html JAuthenticateResponse] type (see link for array keys)
 +
* $options - an associative array containing these keys: ["remember"] => bool, ["return"] => string, ["entry_url"] => string
 +
 
 +
===Return Value===
 
Boolean
 
Boolean
====5.3.2.4 Used in files====
+
===Used in files===
  *libraries/joomla/application/application.php
+
*<tt>libraries/joomla/application/application.php</tt>
  *plugins/user/joomla.php
+
*<tt>plugins/user/joomla.php</tt>
====5.3.2.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
 
+
 
 +
==onUserLogout==
 +
===Description===
 +
This event is triggered before the user is logged out of the system. <del>If one plugin
 +
returns false, the global logout fails.</del> (needs verification)
 +
 
 +
===Parameters===
 +
* $credentials - an associative array containing these keys: ["username"] => string, ["id"] => int
 +
* $options - an associative array containing this key: ["clientid"] => int
  
===5.3.3 onLogoutUser===
+
===Return Value===
====5.3.3.1 Description====
 
This event is triggered before the user is logged out of the system. If one plugin
 
returns false, the global logout fails.
 
====5.3.3.2 Parameters====
 
Array of credentials. Structure:\\
 
['username']\\
 
['id']\\
 
====5.3.3.3 Return Value====
 
 
Boolean
 
Boolean
====5.3.3.4 Used in files====
+
===Used in files===
  *libraries/joomla/application/application.php
+
*<tt>libraries/joomla/application/application.php</tt>
  *plugins/user/joomla.php
+
*<tt>plugins/user/joomla.php</tt>
====5.3.3.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
  
===5.3.4 onAuthenticate===
+
==onUserAuthenticate==
====5.3.4.1 Description====
+
===Description===
 
This event is triggered to verify that a set of login credentials is valid.
 
This event is triggered to verify that a set of login credentials is valid.
====5.3.4.2 Parameters====
+
===Parameters===
 
Array of credentials. Structure:\\
 
Array of credentials. Structure:\\
 
['username']\\
 
['username']\\
Line 65: Line 62:
 
Alternative authentication mechanisms can supply additional credentials.
 
Alternative authentication mechanisms can supply additional credentials.
  
====5.3.4.3 Return Value====
+
===Return Value===
 
An array of [[references:joomla.framework:user:jauthenticateresponse|JAuthenticateResponse]] objects detailing the results of each called plugin, including success or failure.
 
An array of [[references:joomla.framework:user:jauthenticateresponse|JAuthenticateResponse]] objects detailing the results of each called plugin, including success or failure.
====5.3.4.4 Used in files====
+
===Used in files===
  *libraries/joomla/application/user/authentication.php
+
*<tt>libraries/joomla/application/user/authentication.php</tt>
  *plugins/authentication/gmail.php
+
*<tt>plugins/authentication/gmail.php</tt>
  *plugins/authentication/joomla.php
+
*<tt>plugins/authentication/joomla.php</tt>
  *plugins/authentication/ldap.php
+
*<tt>plugins/authentication/ldap.php</tt>
====5.3.4.5 Examples====
+
===Examples===
  *plugins/authentication/example.php
+
*<tt>plugins/authentication/example.php</tt>
  
===5.3.5 onLoginFailure===
+
==onUserLoginFailure==
====5.3.5.1 Description====
+
===Description===
 
This event is triggered whenever a user authentication request is failed by any plugin.
 
This event is triggered whenever a user authentication request is failed by any plugin.
====5.3.5.2 Parameters====
+
===Parameters===
 
Two parameters. The credentials array for the user (see onAuthenticate), and the
 
Two parameters. The credentials array for the user (see onAuthenticate), and the
 
[[references:joomla.framework:user:jauthenticateresponse|JAuthenticateResponse]] that caused the failure.
 
[[references:joomla.framework:user:jauthenticateresponse|JAuthenticateResponse]] that caused the failure.
====5.3.5.3 Return Value====
+
===Return Value===
 
Unknown. The return value appears to be ignored in any case.
 
Unknown. The return value appears to be ignored in any case.
====5.3.5.4 Used in files====
+
===Used in files===
  *libraries/joomla/application/user/authentication.php
+
*<tt>libraries/joomla/application/user/authentication.php</tt>
  
===5.3.6 onBeforeStoreUser===
+
==onUserBeforeSave==
====5.3.6.1 Description====
+
===Description===
 
This event is triggered before an update of a user record.
 
This event is triggered before an update of a user record.
  
 
Password in $user array is already hashed at this point. You may retrieve the cleartext password using $_POST['password'].
 
Password in $user array is already hashed at this point. You may retrieve the cleartext password using $_POST['password'].
  
====5.3.6.2 Parameters====
+
===Parameters===
Three parameters:
+
* $user - An associative array of the columns in the user table (current values).
  *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)
  *id - A unique identifier for this user.
+
Note; You can retrieve the values that are about to get updated with JFactory::getUser();
  *isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)
 
  
====5.3.6.3 Return Value====
+
===Return Value===
 
None
 
None
====5.3.6.4 Used in files====
+
===Used in files===
  *libraries/joomla/user/user.php
+
*<tt>libraries/joomla/user/user.php</tt>
====5.3.6.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
===5.3.7 onAfterStoreUser===
+
 
====5.3.7.1 Description====
+
==onUserAfterSave==
 +
===Description===
 
This event is triggered after an update of a user record, or when a new user has been stored in the database.
 
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'].
 
Password in $user array is already hashed at this point. You may retrieve the cleartext password using $_POST['password'].
  
====5.3.7.2 Parameters====
+
===Parameters===
Four parameters:
+
* '''$user''' - An associative array of the columns in the user table.
  *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)
  *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
  *success - Boolean to identify if the store was successful
+
* '''$msg''' - Error message if store failed
  *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().
  
====5.3.7.3 Return Value====
+
===Return Value===
 
None
 
None
====5.3.7.4 Used in files====
+
===Used in files===
  *libraries/joomla/user/user.php
+
*<tt>libraries/joomla/user/user.php</tt>
====5.3.7.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
  
===5.3.8 onBeforeDeleteUser===
+
==onUserBeforeDelete==
====5.3.8.1 Description====
+
===Description===
 
The event is triggered when a user is about to be deleted from the system.
 
The event is triggered when a user is about to be deleted from the system.
====5.3.8.2 Parameters====
+
===Parameters===
An associative array containing user information. Structure:\\
+
* $user - An associative array of the columns in the user table.
['id']\\
+
 
====5.3.8.3 Return Value====
+
===Return Value===
 
None.
 
None.
====5.3.8.4 Used in files====
+
===Used in files===
  *libraries/joomla/user/user.php
+
*<tt>libraries/joomla/user/user.php</tt>
  *plugins/user/joomla.php
+
*<tt>plugins/user/joomla.php</tt>
====5.3.8.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
  
===5.3.9 onAfterDeleteUser===
+
==onUserAfterDelete==
====5.3.9.1 Description====
+
===Description===
 
The event is triggered after a user has been deleted from the system.
 
The event is triggered after a user has been deleted from the system.
====5.3.9.2 Parameters====
+
===Parameters===
Three parameters: user information, delete result, and error result.
+
* $user - An associative array of the columns in the user table.
User information is an associative array. Structure:\\
+
* $succes - Boolean to identify if the deletion was successful
['id']\\
+
* $msg - Error message if delete failed ([http://api.joomla.org/Joomla-Framework/Error/JError.html JError] object detailing the error, if any)
Delete result is boolean true if the delete succeeded or an error message on failure.\\
+
 
Error result is a [[references:joomla.framework:utilities:jerror|JError]] object detailing the error, if any.
+
===Return Value===
====5.3.9.3 Return Value====
 
 
None.
 
None.
====5.3.9.4 Used in files====
+
===Used in files===
  *libraries/joomla/user/user.php
+
*<tt>libraries/joomla/user/user.php</tt>
  *plugins/user/joomla.php
+
*<tt>plugins/user/joomla.php</tt>
====5.3.9.5 Examples====
+
===Examples===
  *plugins/user/example.php
+
*<tt>plugins/user/example.php</tt>
 +
 
 +
<noinclude>[[Category:Plugin Development]][[Category:Specifications]]</noinclude>

Revision as of 08:16, 26 April 2013

The "J1.5" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Stop hand nuvola.svg.png
Warning!

This page is under migration to Joomla 2.5 new plugin trigger methods


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

The user events are divided into two parts. First we have the events used while authentication of a user takes place:

  • onUserLogin (on Joomla 1.5: onLoginUser)
  • onUserLogout (on Joomla 1.5: onLogoutUser)
  • onUserAuthenticate (on Joomla 1.5: onAuthenticate)
  • onUserAuthorisationFailure (on Joomla 1.5: onAuthenticateFailure)

Second we have the events triggered during user management:

  • onUserBeforeSave (on Joomla 1.5: onBeforeStoreUser)
  • onUserAfterSave (on Joomla 1.5: onAfterStoreUser)
  • onUserBeforeDelete (on Joomla 1.5: onBeforeDeleteUser)
  • onUserAfterDelete (on Joomla 1.5: onAfterDeleteUser)

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 onAuthenticate 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

onUserBeforeSave[edit]

Description[edit]

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

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 (current values).
  • $isnew - Boolean to identify if this is a new user (true - insert) or an existing one (false - update)

Note; You can retrieve the values that are about to get updated with JFactory::getUser();

Return Value[edit]

None

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