- Posts: 27
- Thank you received: 0
Plugin OnBeforeUserCreate
I've created a plugin onBeforeUsercreate :
But it seems that it does'nt launch. My plugin is activated.But when I go to plugin hihashop (System / Plugins), the list is empty.
Where is my mistake ?
Best Regards
Please Log in or Create an account to join the conversation.
The problem come maybe from your XML file.
How do you have made this plugin ? Do you have coded it, and then installed via the Joomla extension manager ?
If not thanks to zip the files and install it via the Joomla installer or use the "discover" function.
Please Log in or Create an account to join the conversation.
I've coded this plugin and installed it via the Joomla extension manager.
This s my xml file :
Best Regards
Please Log in or Create an account to join the conversation.
In all cases, can you try display system messages at many place in order to see if the plugin is called.
Please Log in or Create an account to join the conversation.
Yes, the name of my table is : entreprises without extension.
I've display system messages, var_dump on plugin and die in the class user just after $dispatcher->trigger( 'onBeforeUserCreate', array( & $element, & $do) );
I can see system message from plugin on checkout identification.
Then when I launch user creation with the button : a blank page with no message.
The code of my plugin :
I can see twice 'Votre code entreprise est inconnu' : one with $element->code_entreprise blank and one with $element->code_entreprise fullfilled
If I remove die from user class, the user is created.
I'm lost. Have you got an idea ?
Best Regards
Please Log in or Create an account to join the conversation.
The blank page is due to the "die" but if nothing is displayed, that's probably because you have an error.
Have you enabled the debug mode and set the error reporting level to "maximum" in order to see the errors ?
You var_dump should not be empty.
Please Log in or Create an account to join the conversation.
I've enabled debug.
So some things become clear but another not.
The name of the plugin in hikashop documentation is not right : it's not OnBeforeUserCreate but onUserBeforeSave.
Moreover the parameters seems not be references.
My code is now like that :
Code entreprise is a custom field. This is a part of identification page :
Maybe, I'm wrong in calling parameters ?
Best Regards
Please Log in or Create an account to join the conversation.
First, $element3 is an array, not an object.var_dump($element3)
array(21)
More than that, "onUserBeforeSave" is not an HikaShop trigger, but "onBeforeUserCreate" and "onBeforeUserUpdate" are.
www.hikashop.com/support/support/documen...umentation.html#user
You can't access to HikaShop user custom field is you are looking at the Joomla user (using a Joomla user trigger).
Regards,
Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.
Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
Please Log in or Create an account to join the conversation.
So, i've modifiyed :
My plugin :
The user librairy (user.php) :
The errors now :
Je tourne en rond. Hope there is a solution.
Best Regards
Please Log in or Create an account to join the conversation.
If you look in the class/user.php file you can see that code:
I don't know why that would happen (?), but a simple workaround is to set a negative ordering to your plugin so that it gets called before all the others. Then, that won't be possible that $do is null in your plugin as there will be virtually no code between the trigger and your plugin.
Please Log in or Create an account to join the conversation.
So, i've ordered the plugin code_ent with a negative value (see my first screen image).
But no success : always the error
I wonder if it is normal that the lists of plugin on Hikashop is empty ? (see my second creen image)
Best Regards
Please Log in or Create an account to join the conversation.
Could you give us the corresponding code for the lines "34" and "45" just to be sure of which variable is not an object ?
In HikaShop plugins, you have to click on new in order to enable plugins presents in HikaShop but not enabled by default.
So having nothing in this listing is not a problem.
Please Log in or Create an account to join the conversation.
line 34 : $query='SELECT count(*) FROM entreprises WHERE code = "'.$element->code_entreprise.'"';
line 45 : if ($element->code_entreprise != '')
Best Regards
Please Log in or Create an account to join the conversation.
You should use this code to prevent from errors.
And are you sure that the Column name of your custom field "Code entreprise" in the user table is "code_entreprise" and not, by default, "codeentreprise" ?
Please Log in or Create an account to join the conversation.
I've tried without die and it works.
The plugin is called twice : once without custom fields and another one with them.
Strange
The user Joomla is created but it doesn't access to the next level of checkout.
Is it possible not to create user Joomla ?
Best Regards
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Sorry for the delay but I have to face now the problem.
A question if I use onBeforeStoreUser (Joomla Plugin) , will I have access to the entreprise code (a personnalized info for the user that I've added in hikashop => champ personnalisé) ?
Best Regards
Please Log in or Create an account to join the conversation.
Yes, but in that case, you want to look in the $_POST variable for the custom user field data from HikaShop.
Please Log in or Create an account to join the conversation.