Search code examples
joomla-extensionsjoomla3.3

mysql erros when creating a joomla plugin with onUserAfterSave


I made plug in that authenticates against our XML server that works like charm. But nog now i am trying to make plugin for the function onUserAfterSave so i can do the post login processing, like assign a user to group amongs one this.

But ik can't get the basic's the work.

my extetntion defenition in the xml file looks like this :

<extension version="3.1" type="plugin" group="user">

and the php file like this

    // No direct access
    defined('_JEXEC') or die;
    //include_once "functions.php";

    /**
     * HCC XML-RPC login handler plugin
     *
     * @package Joomla.Plugin
     * @subpackage  User.hcc_xml_handler
     * @since 3.1
     */
    class PlgUserhcc_xml_handler extends JPlugin
    {
        /**
        * This plug process the extra login information.
        *
        *
        * @param   array    $user     Holds the new user data.
        * @param   boolean  $isnew    True if a new user is stored.
        * @param   boolean  $success  True if user was succesfully stored in the database.
        * @param   string   $msg      Message.
        *
        * @return  void
        *
        * @since   1.6
        */
        public function onUserAfterSave($user, $isnew, $success, $msg)
        {
            /*
            $debug = $this->params->get('debug', '0');
            if ($debug == '1')
            {$debugfile = $this->params->get('debugfile', '');}
            else{$debugfile = "";}

            $debug = $this->params->get('debug', '0');
            */
            $debug = '1';
            $debugfile = "/disk/site/hcc.nl/poc-groepen/logging/hcc_xml_handler-debug.log";
            if ($debug == '1')
            {
                // set debug log file if debug is enabled
                $debugstartmsg  = "=====================================\n";
                $debugstartmsg .= "= start hcc_xml_handler.php aanroep =\n";
                $debugstartmsg .= "=====================================\n";
                file_put_contents($debugfile, $debugstartmsg, FILE_APPEND | LOCK_EX);
            }

            if (!$success)
            {
                if ($debug == '1')
                {
                    $debugsuccessmsg = "login gelukt" ;
                    file_put_contents($debugfile, $debugsuccessmsg, FILE_APPEND | LOCK_EX);
                }
                return false;
            }
            if ($isnew)
            {
                if ($debug == '1')
                {
                    $debugnewsmsg = "login NEW" ;
                    file_put_contents($debugfile, $debugnewsmsg, FILE_APPEND | LOCK_EX);
                }
            return false;
            }
            if ($debug == '1')
            {
                // set debug log file if debug is enabled
                $debugstopmsg  = "=====================================\n";
                $debugstopmsg .= "=  stop hcc_xml_handler.php aanroep =\n";
                $debugstopmsg .= "=====================================\n";
                file_put_contents($debugfile, $debugstopmsg, FILE_APPEND | LOCK_EX);
            }


        }
    }

what am i doing wrong ?

the errors i see in the logging are :

mysqli_fetch_row() expects parameter 1 to be mysqli_result, boolean given in /www/libraries/joomla/database/driver/mysqli.php on line 785, referer: https://someurl.hcc.nl/ mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in /www/libraries/joomla/database/driver/mysqli.php on line 828, referer: https://someurl.hcc.nl/

any one an idea?


Solution

  • I switched to function onUserAfterLogin that did it for me