Hello.
I think I have a problem with the "login_after" hook... nothing happens.
I did exactly what was said in the docs. (http://trac.roundcube.net/wiki/Doc_Plugins)
Quotefunction init()
{
#Hook:
$this->add_hook('login_after', array($this, 'enforcepwdchange'));
$rcmail = rcmail::get_instance();
[........]
}
Quote// Check & enforce password change
function enforcepwdchange($args) {
[........]
}
Apparently the hook never gets registered, because I put the following code in rcube_plugin_api.php to debug, inside the function exec_hook:
Quoteif($hook == 'login_after') {
echo "Trying to exec login_after\n";
var_dump((array)$this->handlers[$hook]);
exit;
}
The result on the screen is:
QuoteTrying to exec login_after array(0) { }
So, the array with the callbacks for "login_after" is empty. Am I doing something wrong or is the documentation wrong?
Thank you.
appoligies if this is a stupid question but have you enabled the plugin in your config?
Quote from: JohnDoh;22306appoligies if this is a stupid question but have you enabled the plugin in your config?
You don't need to apologize, I need to, because it's my mistake that I wasn't clear enough.
Yes, the plugin is enabled, and yes, everything else regarding the plugin is working, just the part with the redirect after successful login isn't. The function "enforcepwdchange" never gets called, and aparently, never gets registered.
hmmm i just tried it and its definatly working for me. only other thing i can think of is that you have not set `public $task` correctly. do you have a task set? if you want to use the login_after hook then the task must include 'mail'.
If that doesnt help could you post your code and I can try and see why the hook works for me and not you.
OK, then I guess I have a problem.
The task is "settings", because it's an update for the "password" plugin, I named it "passwordext (http://code.google.com/p/roundcubeplugins/downloads/list)". I integrated some password strength checks in it, and I wanted to also make a mechanism to force a user to change his/her password, because most of the users on the mail server I administer have very weak passwords (like username is "
[email protected]", and the password is "office"...). I was thinking about redirecting a user to the password change immediately after they login, with a warning that they must change password.
What I should do? Can I have two tasks in the same plugin if I define them as an array?
I'm sorry that I ask all this here, but I don't find it anywhere in the docs... :(
no problem. you can assing multiple tasks like this....
public $task = 'mail|settings';
Thank you, it's working. You can close this now.
Now I can get to work on the enforce password change part. :)
P.S.
Someone should update the docs here (http://trac.roundcube.net/wiki/Plugin_Hooks#login_after) and specify that "login_after" is a "mail" task, not general.