Reputation: 3
My code in user file-
I am trying to onUserBeforeSave, but in this event, Joomla code is executed, control does not come to my code:
class PlgUserotp extends JPlugin
{
public function onUserBeforeSave($oldUser,$isnew,$newuser)
{
$errors = NULL;
$phone_number = NULL;
foreach ($newuser as $key => $value)
{
if($key=="username")
$username = $value;
elseif ($key=="email1")
$email = $value;
elseif ($key=="password1")
$password = $value;
else
$extra_data[$key]=$value;
}
//echo $username . $email .$password;
$this->startVerificationProcess($username,$email,$errors,$phone_number,$password,$extra_data);
//MoCurlOTP::mo_send_otp_token('EMAIL',$newuser["email1"],'');
}
}
Upvotes: 0
Views: 147
Reputation: 4271
The first step in debugging this issue is to make sure that your plugin is really being loaded. First add a die('In my plugin');
at the very beginning and see if it's really dying. If that's the case, then this means that Joomla is really loading your plugin (if it's not, then check that your plugin is enabled, also check that the System - cache plugin is disabled, just in case).
The next step is to make sure that Joomla is instantiating your plugin object, and this is done by adding a construct
method, and then adding a die('In constructor');
in that function. If it's not displaying this message, then this means that your class name is not in line with the class name defined in your XML manifest file.
The last step is to check whether the onUserBeforeSave
is really being triggered, by adding a die('In onUserBeforeSave');
at the very beginning of the function. If it's not triggered, then try debugging the file libraries/src/User/User.php
(I'm assuming you're using Joomla 3.8.x), as the this event is triggered from there. If is being triggered, then this means that your code is working, but has no effect.
Upvotes: 1