I need to check to see if at least one phone number is provided before a user is either created or updated, and if not, throw an error. I enabled the skeleton plugin, but can't figure out how to do it. Here is my code:
defined('_JEXEC') or die;
class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user,&$data,$changed,$isNew){
if ($data['homephone'] == '' && $data['cellphone'] == ''){
JFactory::getApplication()->enqueueMessage('You need at least one phone number.', 'Error');
}
else {
$user->save();
}
}
}
However, when I save a user with no phone numbers, I get no error message and the user is saved. I am sure the fix is simple, I just don't know what it is.
Thanks.