[PLUGIN] Send a form through onAfterUserCreate

  • Posts: 6
  • Thank you received: 0
10 years 5 months ago #159740

-- url of the page with the problem -- : Localhost
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.3.0
-- PHP version -- : 5.5.10
-- Browser(s) name and version -- : All
-- Error-message(debug-mod must be tuned on) -- : There is no error message, it just dont send the email.

Hi guys,

I am trying to auto send a form once the user register in Hikashop.

I have create this plugin and place it inside root/plugins/hikashop/hikaforce.

here is the function

class plgHikashopHikaforce extends JPlugin
{

function onAfterUserCreate(&$element){


This commented bit is for testing and it works fine. it does redirect to this file and send submit the form as I desire.

// $link = JURI::root()."plugins/hikashop/hikaforce/redirect_data.php";
// $msg = 'Testing Redirect';
// $app = JFactory::getApplication();
// $app->redirect($link, $msg);



However if I try to echo inside the function onAfterUserCreate it does not send.
echo '<form id="force" name="force" action=" www.example.com " method="POST">';
echo '<input type=hidden name="code" value="LP_WEB" >';
echo '<input type=hidden name="first_name" value="first_name">';
echo '<input type=hidden name="last_name" value="last_name">';
echo '</form>';
echo '<script type="text/javascript">';
echo 'document.getElementById("force").submit();';
echo '</script>';

}
I also have put it inside a variable called $output and return it... did not work either.

What am I doing wrong.

Thanks in advance

Last edit: 10 years 5 months ago by Fit_webmaster.

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 0
10 years 5 months ago #159836

Anyone?

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 5 months ago #159858

Hi,

When doing an echo, it is not displayed because there is no views, it's just an action which should be made.
In your code, there is missing double quotes around the "hidden" word for the inputs.

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 0
10 years 5 months ago #159995

I have added those quotes to it and it did not work... so I have changed quite a bit the code... I am very close to it... just need to know how to retrieve the data from #__hikashop_address..

Here is the code:

$query = "SELECT * FROM #__hikashop_address WHERE address_user_id = ".$element->user_cms_id;
$db->setQuery($query);
$result = $db->loadObjectList();


I will work on it now, but would be great to get some response.
foreach ($result as $r){
echo $r->xyz
}


OR

How can I get the data from the form? like last name, postcode, city, telephone so on?
$element->city ??


Cheers Xavier

Last edit: 10 years 5 months ago by Fit_webmaster.

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 5 months ago #159998

Try like that instead:
$query = "SELECT * FROM #__hikashop_address WHERE address_user_id = ".$element->user_id;
$db->setQuery($query);
$result = $db->loadObjectList();

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 0
10 years 5 months ago #160331

Got this... Xavier [HikaShop] helped me.
The problem was that when using onAfterUserCreate the Address array is not yet created. Once I changed my trigger method to onAfterAddressCreate I could echo Address and pull the user instead.
Thanks

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum