Author Topic: How to save "extra plugin parameters" when creating userfield plugin.  (Read 678 times)

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 41
    • UWiX
  • VirtueMart Version: 3.x
I am developing a simple userfield plugin which should check some user profile settings. It does not need any table to store records or something like the included virtuemart realex_hpp_api plugin does.

Now I've added one option in the xml of the plugin to show up on the extra plugin parameters field when defining the shopper field details. And it displays as it should but when saving the defined field this parameter isn't stored in the "userfield_params" column in the #__virtuemart_userfields table.

The following codes are added to the plugin:

Code: [Select]
var $varsToPush = array( 'checkUserProfile'=>array(0.0,'bool')   ); // Global variable to use
In the ___construct function added:
Code: [Select]
$this->setConfigParameterable('userfield_params', $this->varsToPush); // As described in the documentation
In the plgVmPrepareUserfieldDataSave function added:
Code: [Select]
$this->storePluginInternalData($params); // Save parameters ($params is taken from the function variable)But that function does not seem te be called at all ;-(

Also tried to add the storePluginInternalData call in the plgVmOnBeforeUserfieldSave function - but that doesn't work either.

What am I missing here? I cannot seem to find the correct way to store the selected parameter value into the correct array or function to save it to the database.
If any of you have an idea or a solution or some clear documentation on it... That would be very nice!  ;D

-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to save "extra plugin parameters" when creating userfield plugin.
« Reply #1 on: February 13, 2018, 20:51:42 pm »
In the plgVmPrepareUserfieldDataSave function added:
Code: [Select]
$this->storePluginInternalData($params); // Save parameters ($params is taken from the function variable)But that function does not seem te be called at all ;-(

Sad that I did not see this post earlier. The answer is just that the storePluginInternalData is the user data of the plugin. You want to store the configuration of the plugin, right?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

UWiX

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 41
    • UWiX
  • VirtueMart Version: 3.x
Re: How to save "extra plugin parameters" when creating userfield plugin.
« Reply #2 on: February 13, 2018, 21:06:49 pm »
Yes, that's right. The plugin parameters which are added as described in my 'problem' description.  And better late than....  ;D Thank you for the reply!
-- Beam me up Scotty! This isn't the mens room!
-- Using VirtueMart 3.x

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9667
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: How to save "extra plugin parameters" when creating userfield plugin.
« Reply #3 on: February 14, 2018, 10:23:37 am »
You need in the constructor this (as you posted)
Code: [Select]
$this->setConfigParameterable ('customfield_params', $varsToPush);

and this
Code: [Select]
function plgVmDeclarePluginParamsCustomVM3(&$data){
return $this->declarePluginParams('custom', $data);
}

and this
Code: [Select]
function plgVmGetTablePluginParams($psType, $name, $id, &$xParams, &$varsToPush){
return $this->getTablePluginParams($psType, $name, $id, $xParams, $varsToPush);
}


When you have this triggers, you just need the data as array and the stuff is automatically stored as parameter.
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/