Reputation: 4866
When accessing com_users component in Joomla 1.6 and 1.7 on front-end the application automatically imports all plugins from 'user' group. Obviously it is very useful if one doesn't want to create a component to simply pass some variables to a plugin.
Ok. let's make it simplier:
Basically, with plugin's __constructor one can set up simple action like this one below:
class plgUserAccountactivation extends JPlugin
{
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
if(isset($_GET['emailactivation'])) {
// check token
// activate account, email or whatever
// redirect with message
}
}
}
Wow! It works, it is not necessary to create a whole controller to handle one simple task.
But hold on a minute...
Hey, hey, nothing happens com_user didn't import anything at all and __constructor wan't called.
I am very troubled by this in Joomla 1.5 and I don't feel like writing whole component.
Should anybody have some bright idea, please let me know.
Edit: I've solved my problem by sending the link in the following form:
http:/example.com/index.php?option=com_user&task=logout&emailactivation=1&u=63&d077b8106=1
This way user plugins are included and __constructors are executed. But this is so frivolous as task=logout doesn't really encourage to click in the link.
Upvotes: 3
Views: 1070
Reputation: 969
The problem with 1.5 is, that events are more limited. You have the following events available: Joomla 1.5 Plugin Events - User. I guess therefore your plugin is not initiated.
How about making this a system plugin and checking for the activation in the URL/request properties? Something like:
class plgSystemUseractiavation extends JPlugin {
function onAfterInitialise(){
$u = &JURI::getInstance();
$option = trim(strtolower($u->getVar('option')));
$emailactivation = trim(strtolower($u->getVar('emailactivation')));
if( strlen($option < 1) ){ // for SEF...
$option = trim(strtolower(JRequest::getString('option')));
}
$app =& JFactory::getApplication();
$appName = trim(strtolower($app->getName()));
if( $appName === 'site' ){
if( ( $option === 'com_users' ) || ( $option === 'com_user' ) ){
if( $emailactivation === '1' ){
// check token
// activate account, email or whatever
// redirect with message
}
}
}
}
}
Upvotes: 1